spring-rabbit

Spring rabbit retries to deliver rejected message..is it OK?

只愿长相守 提交于 2019-12-01 09:30:48
I have the following configuration spring.rabbitmq.listener.prefetch=1 spring.rabbitmq.listener.concurrency=1 spring.rabbitmq.listener.retry.enabled=true spring.rabbitmq.listener.retry.max-attempts=3 spring.rabbitmq.listener.retry.max-interval=1000 spring.rabbitmq.listener.default-requeue-rejected=false //I have also changed it to true but the same behavior still happens and in my listener I throw the exception AmqpRejectAndDontRequeueException to reject the message and enforce rabbit not to try to redeliver it ...But rabbit redilvers it for 3 times then finally route it to dead letter queue.

How to Achieve Concurrency With a Non-Thread-Safe MessageListener

折月煮酒 提交于 2019-12-01 06:31:36
The answer to this question explains how to use prototype scope with <rabbit:listener-container/> in Spring AMQP when the listener is not thread-safe. Another user asked (in a comment) how to configure the same environment using only Java Configuration. It's generally best practice to use stateless beans for listeners but when that's not possible, to configure @Prototype scope listener (and multiple containers) using only Java Configuration, you can use: @Bean public SimpleMessageListenerContainer container1() { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer

Spring Cloud Stream message from/to JSON conversion configuration

泄露秘密 提交于 2019-12-01 05:31:36
I am using Spring Cloud Stream, with RabbitMQ binder. It works great with byte[] payload and Java native serialization, but I need to work with JSON payload. Here's my processor class. @EnableBinding(Processor.class) public class MessageProcessor { @ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT) public OutputDto handleIncomingMessage(InputDto inputDto) { // Run some job. return new OutputDto(); } } InputDto and OutputDto are POJOs with Jackson annotations. How do I configure JSON conversion strategy? How should message headers look like to be accepted and

Spring Cloud Stream message from/to JSON conversion configuration

旧巷老猫 提交于 2019-12-01 03:48:45
问题 I am using Spring Cloud Stream, with RabbitMQ binder. It works great with byte[] payload and Java native serialization, but I need to work with JSON payload. Here's my processor class. @EnableBinding(Processor.class) public class MessageProcessor { @ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT) public OutputDto handleIncomingMessage(InputDto inputDto) { // Run some job. return new OutputDto(); } } InputDto and OutputDto are POJOs with Jackson annotations.

How to write an integration test for @RabbitListener annotation?

烈酒焚心 提交于 2019-11-29 14:22:45
My question is really a follow up question to RabbitMQ Integration Test and Threading There it states to wrap "your listeners" and pass in a CountDownLatch and eventually all the threads will merge. This answer works if we were manually creating and injecting the message listener but for @RabbitListener annotations... i'm not sure how to pass in a CountDownLatch. The framework is auto magically creating the message listener behind the scenes. Are there any other approaches? Selwyn With the help of @Gary Russell I was able to get an answer and used the following solution. Conclusion: I must

Dynamically add new queues, bindings and exchanges as beans

空扰寡人 提交于 2019-11-29 06:14:39
I'm currently working on a rabbit-amqp implementation project and use spring-rabbit to programmatically setup all my queues, bindings and exchanges. (spring-rabbit-1.3.4 and spring-framework versions 3.2.0) The declaration in a javaconfiguration class or xml-based configuration are both quite static in my opinion declared. I know how to set a more dynamic value (ex. a name) for a queue, exchange or binding like this: @Configuration public class serverConfiguration { private String queueName; ... @Bean public Queue buildQueue() { Queue queue = new Queue(this.queueName, false, false, true,

Spring amqp with RabbitMq: Message is not circled back to live queue after falling off dead letter queue

荒凉一梦 提交于 2019-11-28 14:25:39
I am trying to achieve this . There are so many conflicting answers to know if its possible or not. According to previous link, it is not possible. But in another question on this forum, somebody remarked that they were able to here and in the comment section here . So, Is it possible to do live queue => dead-letter-queue => live queue Or do I need to use a particular version of RabbitMq to achieve this ? I am able to do: live queue => dead-letter-queue and dead-letter-queue => live queue. You can't do it if the dead-lettering from alive is due to expiry - according to the documentation... It

Spring RabbitMQ - using manual channel acknowledgement on a service with @RabbitListener configuration

允我心安 提交于 2019-11-27 19:30:38
How to acknowledge the messages manually without using auto acknowledgement. Is there a way to use this along with the @RabbitListener and @EnableRabbit style of configuration. Most of the documentation tells us to use SimpleMessageListenerContainer along with ChannelAwareMessageListener . However using that we lose the flexibility that is provided with the annotations. I have configured my service as below : @Service public class EventReceiver { @Autowired private MessageSender messageSender; @RabbitListener(queues = "${eventqueue}") public void receiveMessage(Order order) throws Exception {

Spring amqp with RabbitMq: Message is not circled back to live queue after falling off dead letter queue

雨燕双飞 提交于 2019-11-27 08:33:16
问题 I am trying to achieve this. There are so many conflicting answers to know if its possible or not. According to previous link, it is not possible. But in another question on this forum, somebody remarked that they were able to here and in the comment section here. So, Is it possible to do live queue => dead-letter-queue => live queue Or do I need to use a particular version of RabbitMq to achieve this ? I am able to do: live queue => dead-letter-queue and dead-letter-queue => live queue. 回答1:

Spring RabbitMQ - using manual channel acknowledgement on a service with @RabbitListener configuration

一曲冷凌霜 提交于 2019-11-26 19:38:21
问题 How to acknowledge the messages manually without using auto acknowledgement. Is there a way to use this along with the @RabbitListener and @EnableRabbit style of configuration. Most of the documentation tells us to use SimpleMessageListenerContainer along with ChannelAwareMessageListener . However using that we lose the flexibility that is provided with the annotations. I have configured my service as below : @Service public class EventReceiver { @Autowired private MessageSender messageSender