spring-amqp

What is the difference between prefetch count vs no ack in rabbitmq

自闭症网瘾萝莉.ら 提交于 2019-12-01 09:45:38
问题 I need to know what is the difference between prefetch count vs no ack in rabbitmq ? Also What is the difference between following statements :- if i set prefetch count say 10 does 10 consumer threads are created ? Or -- if i register 10 cosumers will it create 10 threads ? Which of the above is more efficient 回答1: Pre-fetch count: How many messages the consumer should read from queue and kept internally rather than picking one message at a time. No-Ack: Do not acknowledge back that the

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.

SimpleMessageListenerContainer Error Handling

こ雲淡風輕ζ 提交于 2019-12-01 09:19:24
问题 I'm using a SimpleMessageListenerContainer as a basis for remoting over AMQP. Everything goes smooth provided that the RabbitMQ broker can be reached at process startup. However, if by any reason it can't be reached (network down, permissions problem, etc...) the container just keeps retrying to connect forever. How can I set up a retry behaviour in this case (for example, try at most 5 times with an exponential backoff and then abort, killing the process)? I've had a look at this, but it

Spring AMQP: Register BlockedListener to Connection

人走茶凉 提交于 2019-12-01 09:06:56
问题 I am trying to implement Blocked Listeners to RabbitMQ using RabbitTemplate of Spring AMQP. In my code i am using Spring-amqp 1.1.3 version jar file, whereas i have looked into the version 1.3.1 as well and this is unsupported in this version also. Does anyone know if i am missing any version which has support of registering Blocked listeners to the new connections in RabbitMQ. Or if is there any future release of spring amqp to support this feature. Example Code: Connection connection =

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

Scheduled/Delay messaging in Spring AMQP RabbitMq

一笑奈何 提交于 2019-12-01 03:37:04
问题 I am struggling hard to find out the way for scheduled/Delaying messages in Spring AMQP/Rabbit MQ. After hell lot of searching still I am not able to do that in Spring AMQP. Can someone please tell me how to do x-delay in Spring AMQP. I want to Delay a message if some exception occurs in the consumer side. RabbitMQ says to add x-delay and install the plugin which I have already done, but still messages is comming immediately without any delay I am getting this in message Received <(Body:'[B

Spring AMQP v1.4.2 - Rabbit reconnection issue on network failure

早过忘川 提交于 2019-12-01 02:50:21
I am testing the following scenario in Spring AMQP v1.4.2 and it fails to reconnect after a network disruption: Start the spring application which consumes messages asyncly using rabbit:listener-container and rabbit:connection-factory (detailed configuration follows). The log shows that application is successfully receiving messages. Make RabbitMQ invisible to the app by dropping inbound network traffic on rabbit server: sudo iptables -A INPUT -p tcp --destination-port 5672 -j DROP Wait for at least 3 minutes (for network connections to timeout). Fix the connection with: sudo iptables -D INPUT

Spring AMQP v1.4.2 - Rabbit reconnection issue on network failure

五迷三道 提交于 2019-11-30 22:37:11
问题 I am testing the following scenario in Spring AMQP v1.4.2 and it fails to reconnect after a network disruption: Start the spring application which consumes messages asyncly using rabbit:listener-container and rabbit:connection-factory (detailed configuration follows). The log shows that application is successfully receiving messages. Make RabbitMQ invisible to the app by dropping inbound network traffic on rabbit server: sudo iptables -A INPUT -p tcp --destination-port 5672 -j DROP Wait for

Spring AMQP Project with 2 queue's

天涯浪子 提交于 2019-11-30 16:18:36
I'm working on a project that involves 2 queue's, and multiples Listeners interacting with them. Flow: New HTTP request comes to the server, then it's converted into a Object that will be the message This message has to be published in two queues I have two types of Listeners that get messages from each queue and then I do whatever I want I've been reading and the best way to do is with a fanout-exchange. Here is my code: listener-configuration.xml <!-- CREATE CONNECTION FACTORY --> <rabbit:connection-factory id="connectionFactory" host="localhost" username="guest" password="guest" /> <rabbit

How to stop consuming messages with @RabbitListener

扶醉桌前 提交于 2019-11-30 07:55:46
When I use MessageListenerAdapter to handle message, I could call SimpleMessageListenerContainer.stop() to stop consume from the queue. But after I change to use @RabbitListener to listen, I can't find a method like this. I tried CachingConnectionFactory.stop() but doesn't work. Could anyone help? Thank you very much. Give the @RabbitListener an id . Get a reference to the listener endpoint registry bean by autowiring etc. Calling stop() on the registry will stop all containers. Call getListenerContainer(id).stop() to stop an individual container. 来源: https://stackoverflow.com/questions