Spring AMQP RabbitMQ send a message to receive x-queue-type error

You receive an error message when using Spring AMQP send a message to the RabbitMQ:

inequivalent arg 'x-queue-type' for queue 'com.ossez.real.estate' in vhost '/': received none but current is the value 'classic' of type 'longstr', class-id=50, method-id=10

 

The above error message is very clear, indicating that the transmitted message queue parameter less x-queue-type this parameter.

In the code, we create a queue parameters as follows:

return new Queue(MY_QUEUE_NAME, NON_DURABLE);

This directly create less args.put ( "x-queue-type", "classic") queue parameters;

Therefore, we need to add the above parameters when creating the queue.

Modify the code as follows:

Map<String, Object> args = new HashMap<>();
// // set the queue with a dead letter feature
args.put("x-queue-type", "classic");

return new Queue(MY_QUEUE_NAME, NON_DURABLE, false, false, args);

Please refer to GitHub code:

https://github.com/cwiki-us-demo/tutorials/blob/master/spring-amqp/src/main/java/com/baeldung/springamqp/simple/HelloWorldMessageApp.java

https://blog.ossez.com/archives/3050

Guess you like

Origin www.cnblogs.com/huyuchengus/p/11666277.html