Tag Archives: RabbitMQ

[Solved] Fatal message conversion error; message rejected; it will be dropped or routed to a dead letter exchan

When rabbitmq is used, the message deserialization fails, with the following exception:
fatal message conversion error; message rejected; It will be dropped or routed to a dead letter exchange, if so configured

after location analysis, the reason is that the serialization conversion jackson2jsonmessageconverter is set on the production side of MQ messages, and the default serialization class is simplemessageconverter. And the deserialization conversion is not set on the consumer side.

Solution:
because the message is a JSON string, use string to receive parameters, and then use JSON tool class to convert it into an object;

import com.alibaba.nacos.client.utils.JSONUtils;
import com.atguigu.rabbit.common.constant.MqConst;
import com.atguigu.yygh.sms.service.SMSService;
import com.atguigu.yygh.vo.sms.SmsVo;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class SmsReceiver {

    @Autowired
    private SMSService smsService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = MqConst.QUEUE_SMS, durable = "true"),
            exchange = @Exchange(value = MqConst.EXCHANGE_DIRECT_SMS),
            key = {MqConst.ROUTING_SMS}
    ))
    public void send(
            String json,//Receive the transmitted content
            Message message, Channel channel) {
        SmsVo smsVo = null;
        try {
            //Convert the json string into the corresponding object
            //JSONUtils pack name(com.alibaba.nacos.client.utils.JSONUtils)
            smsVo = (SmsVo) JSONUtils.deserializeObject(json, SmsVo.class);
            System.out.println(smsVo);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

rabbit.listener.BlockingQueueConsumer$DeclarationException: Failed to declare queue(s)-2021-10-09

  Today’s Bug

I   Error: failed to start the order micro service. The message listening class cannot find the queue

org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException:   Failed   to   declare   queue(s):[queue.ordertimeout]

  2、 Reason:   The configured dead letter queue is invalid and cannot be found

3、 Review the following configuration steps:

        1. Create switch: exchange.ordertimeout – & gt; Fanout type

        2. Create queue: queue.ordertimeout

        3. Bind switch exchange.ordertimeout and queue.ordertimeout

        4. Create queue.ordercreate

                (1) Arguments1: s-message-ttl=10000

                (2) Arguments2: x-dead-letter-exchange: exchange.ordertimeout  

          5. Principle: after creating an order – & gt; The lifetime of message queue.ordercreate is 10 seconds – & gt; After expiration, enter the dead letter exchange.ordertimeout – & gt;   Forward to message queue.ordertimeout  

[Solved] Rabbitmq Server Error: unable to perform an operation on node ‘rabbit@nscczzms‘. P

Rabbitmq server reports error: unable to perform an operation on node ‘ rabbit@nscczzms ‘. Please see diagnostics information and suggestions below

Step 1: check the rabbitmq service status:

systemctl status rabbitmq-server.service

Viewing rabbitmq error message: rabbitmqctl status

The above problem occurs: modify the hosts file CD/etc VI hosts

127.0.0.1 the name nscczzms// nscczzms must be consistent with the name circled in the picture above.

Then save and exit

Finally, restart rabbitmq: systemctl restart rabbitmq server

Rabbitmq reported an error installing the web interface plug-in

Rabbitmq reported an error installing the web interface plug-in

Recently, when installing rabbitmq plugins, I reported the following errors. I don’t know why. I have been online Baidu a lot and tried a lot. These steps are summarized. I hope I can help you:

Error:
[ root@sa software]# rabbitmq-plugins enable rabbitmq_ management
Enabling plugins on node rabbit@sa :
rabbitmq_ management
Error:
{:query, : rabbit@sa , {: badrpc,: timeout}}

solution:

    first enter: “hostnamectl” to view your own hostname
    , then enter “VI/etc/hosts” to set your own hostname (Note: here is your own IP address + hostname, for example: 172.12.1.68 admin) , and finally run again: rabbitmq plugins enable rabbitmq_ management

Come on, come on, work together!!!

Ambqpioexception of rabbitmq error: java.io.ioexception

org.springframework.amqp.AmqpIOException: java.io.IOException

at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:71)
at org.springframework.amqp.rabbit.connection.RabbitAccessor.convertRabbitAccessException(RabbitAccessor.java:116)
at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:2103)
at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2050)
at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2030)
at org.springframework.amqp.rabbit.core.RabbitAdmin.initialize(RabbitAdmin.java:591)

The error reports are as follows:
if this problem occurs because you are writing the expired section, it is probably because you are in the same queue.

1. The expiration time of the previous queue is modified in the later code

2. When declaring the queue, the exclusive attribute is specified as true. This attribute indicates whether there can be exclusive. There can only be one consumer listener queue. When cnnection is closed. Whether to delete the queue. If true is set, an error will be reported when multiple services are connected to the consumer

Error: unable to perform an operation on node ‘rabbit@rabbitma‘ please see diamostics infoxmation

Error: unable to perform an operation on node ‘ rabbit@rabbitma ’ please see diamostics infoxmation and suagestions below.

At this time, check with rabbitmqctl status

If there is an error, the following message will be displayed

At this time, circle the words in red on the first line

Directly use echo 192.168.174.131 rabbitmq & gt& gt;/ Etc/hosts where IP is the server IP

At this time, restart rabbitmq and you can start quickly

systemctl restart rabbitmq-server.service

After startup, use
rabbitmqctl status to check, and the correct information will be displayed

Rabbitmq failed to stop normally: ERROR: node with name “rabbit” already running on “localhost”

ERROR: node with name “rabbit” already running on “localhost”
[root@localhost init.d]# rabbitmqctl stop
Stopping and halting node rabbit@localhost
Error: unable to connect to node rabbit@localhost: nodedown
ERROR: node with name “rabbit” already running on “localhost”//Common rabbitmq commands
service rabbitmq-server   start
service rabbitmq-server   stop
service rabbitmq-server   status
service rabbitmq-server   rotate-logs|
service rabbitmq-server   restart
service rabbitmq-server   condrestart
service rabbitmq-server   try-restart
service rabbitmq-server   reload
service rabbitmq-server   force-reload
service rabbitmq-server   -detached    //Start in the background
ps -ef | grep rabbitmq View rabbitMq processes
netstat -anplt | grep LISTEN rabbitmq listens on port 15672/5672 by default
Currently, the only way to stop the process is to find the PID

[Solved] Rabbitmq Warning: java.net.SocketException: socket closed

Abnormal log appears in the background:

java.net.SocketException: socket closed

crcimpl.ForgivingExceptionHandler An unexpected connection driver error occured

Note:

RabbitMQ will open 3 ports, 5672, 15672, 25672, of which 5672 is used to provide message queue service, 15672 is used to enable background http access,
and 15672 is not opened by default.

1. Open port 5672 on the server.

Open port 5672:
firewall-cmd –zone=public –add-port=5672/tcp –permanent
Reload:
firewall-cmd –reload

2. Modify the port in the project to 5672

spring:
application:
name: config-client
rabbitmq:
host: localhost
port: 5672
username: admin
password: 123456
virtual-host: /
3. The user has operation authority on the virtual host.

RabbitMQ:address (cannot connect to host/port) [How to Solve]

Scene

[root@taishan-atlas init.d]# service rabbitmq-server start
Failed to get D-Bus connection: Operation not permitted
ERROR: epmd error for host taishan-atlas: address (cannot connect to host/port)

Solution

Modify/etc/hosts and add 127.0.0.1         taishan-atlas

127.0.0.1       localhost
127.0.0.1       taishan-atlas
192.168.12.42   taishan-atlas

Note: here 127.0.0.1 Taishan Atlas 192.168.12.42 Taishan atlas corresponds to the IP address in front of the host name. One is the loopback IP address and the other is the real IP address of the device. If the real IP address is not configured correctly, a similar problem will occur: error: epmd error for host Taishan Atlas: address (cannot connect to host/port)

Note: the reason why you need to manually add a local domain name is that you have modified the local machine’s host name, so you need to modify it accordingly. After the system is installed, a host name will be generated by default

Rabbitmq: Erlang distribution failed solution

Preface
System version: CentOS Linux release 7.7.1908 (Core)
Adding a user to rabbitmq via the rabbitmqctl add_user admin 12345 command prompts an error.
[root@localhost perl]# rabbitmqctl add_user admin 12345
Error: unable to connect to node rabbit@localhost: nodedown
DIAGNOSTICS
===========
attempted to contact: [rabbit@localhost]
rabbit@localhost:
* connected to epmd (port 4369) on localhost
* epmd reports node ‘rabbit’ running on port 25672
* TCP connection succeeded but Erlang distribution failed
* Authentication failed (rejected by the remote node), please check the Erlang cookie

current node details:
– node name: ‘rabbitmq-cli-49@localhost’
– home dir: /root
– cookie hash: BgvEr+lGkDjLTQzT85cpyw==

 

Solution:
1)Search the .erlang.cookie file
[root@localhost mnesia]# find/-name *.cookie
/root/.erlang.cookie
/opt/rabbitmq_server-3.6.10/.erlang.cookie
2)Overwrite the /root/.erlang.cookie file
cp /opt/rabbitmq_server-3.6.10/.erlang.cookie  /root/

Cause:
RabbitMQ’s .erlang.cookie conflicts with the user’s cookie and needs to override the user’s cookie with RabbitMQ’s cookie

RabbitMQ Error: {:plugins_not_found:[xxxx]}

Enter the instruction rabbitmq plugins enable rabbitmq management

appear   RabbitMQ Error: {:plugins_ not_ Found, [: rabbitmq management]} error prompt

It’s because the instruction is misspelled. It’s correct as follows:

rabbitmq-plugins enable rabbitmq_ Management (“-” changed to “)

You can also view the help through the rabbitmq plugins list command