发送消息到RabbitMQ DLQ

时间:2018-10-29 14:50:32

标签: spring-boot rabbitmq

我想在发送到普通队列时发生异常时将消息发送到DLQ。我在春季进行了RabbitMQ配置,但是在出现异常时仍不会将消息发送到DLQ。

    @Bean
TopicExchange exchange()
{
    return new TopicExchange(rabbitTemplate.getExchange());
}

@Bean
Queue dlqNotificationQueue () {
    Map<String, Object> arguments = new HashMap<>()
    arguments.put("x-dead-letter-exchange", rabbitTemplate.getExchange());
    arguments.put("x-dead-letter-routing-key", dqlNotificationQueueName);
    Queue queue = new Queue(dqlNotificationQueueName, true, false, false, arguments)
    return queue
}

@Bean
Binding binding(Queue notificationQueue, TopicExchange exchange)
{
    return BindingBuilder.bind(notificationQueue).to(exchange).with(notificationQueueName);
}

@Bean
Binding bindingDeadLetter(Queue dlqNotificationQueue, TopicExchange exchange)
{
    return BindingBuilder.bind(dlqNotificationQueue).to(exchange).with(dqlNotificationQueueName);
}

@Bean     RabbitListenerErrorHandler errorHandler(){         返回新的com.bisnode.vinland.ng.companygsrl7service.batchservice.RabbitRetryHandler()     }

不确定我是否需要配置更多

0 个答案:

没有答案