问题
Here are my beans:
@Bean
public Queue igSmev3ListenerQueue() {
Map<String, Object> args = new HashMap<>();
args.put("x-dead-letter-exchange", rabbitIgSmev3DlxProperties.getExchangeName());
args.put("x-dead-letter-routing-key", rabbitIgSmev3DlxProperties.getRoutingKey());
return new Queue(rabbitIgSmev3ListenerProperties.getQueueName(), true, false, false, args);
}
@Bean
public Queue igSmev3DlxQueue() {
return new Queue(rabbitIgSmev3DlxProperties.getQueueName(), true, false, false);
}
Here are application.yml settings:
listener:
vhost: /
exchangeName: igSmev3Listener
queueName: igSmev3-ListenerQueue
routingKey: igSmev3-Listener
dlx:
vhost: /
exchangeName: igSmev3Dlx
queueName: igSmev3-DlxQueue
routingKey: igSmev3-Dlx
My current error:
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'x-dead-letter-exchange' for queue 'igSmev3-ListenerQueue' in vhost '/': received none but current is the value 'igSmev3Dlx' of type 'longstr', class-id=50, method-id=10)
How can I solve it? I need to take dead letters from listenerQueue and put them to dlxQueue
回答1:
inequivalent arg 'x-dead-letter-exchange' for queue 'igSmev3-ListenerQueue' in vhost '/': received none but current is the value 'igSmev3Dlx' of type 'longstr'
That means that you have a igSmev3-ListenerQueue
queue on the broker already and it is without an 'x-dead-letter-exchange' argument. Probably you have created it before with that state.
Consider to remove this queue before starting your application with already DLX provided.
来源:https://stackoverflow.com/questions/62792713/how-to-set-x-dead-letter-exchange-in-rabbit