spring-amqp

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

六月ゝ 毕业季﹏ 提交于 2019-12-09 03:16:55
问题 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. 回答1: 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

Notifying channel shutdown to classes implementing the org.springframework.amqp.rabbit.connection.ConnectionListener

送分小仙女□ 提交于 2019-12-08 07:00:45
问题 We use the ConnectionListener interface provided by Spring-AMQP to keep a tab on the underlying connection. The channel is created with autorecovery with a heartbeat set to 10 mins (for some product needs). My observation is the connectionListener.onClose() method does not get called for almost 10 mins even after the underlying rabbitMQ has died. We also do a health status check on the API and use the connectionListener.isOpen() method to determine the state of the connection. And because of

Spring integration - AMQP backed message channels and message conversion

↘锁芯ラ 提交于 2019-12-08 04:34:41
问题 I am trying to use AMQP-backed message channels in my Spring Integration app, but I think I am fundamentally misunderstanding something, specifically around the Message<?> interface and how instances of GenericMessage<?> are written to and read from, a RabbitMQ queue. Given I have a Spring Integration app containing the following domain model object: @Immutable class Foo { String name long quantity } and I declare an AMQP backed message channel called fooChannel as follows: @Bean public

Spring AMQP exception handling basics

血红的双手。 提交于 2019-12-08 00:57:19
问题 I have a Listener class (that implements Spring's MessageListener interface) where I need to not requeue any messages if an exception occurs, but I want to post the message to a different queue. It seems like I need the Listener to catch an AmqpRejectAndDontRequeueException , but I've read that I need it to throw the exception instead. If I do that, I can't re-post the message. Should I just catch a plain Exception and do the re-post there? Is there any need to actually throw the

Notifying channel shutdown to classes implementing the org.springframework.amqp.rabbit.connection.ConnectionListener

倖福魔咒の 提交于 2019-12-07 20:17:37
We use the ConnectionListener interface provided by Spring-AMQP to keep a tab on the underlying connection. The channel is created with autorecovery with a heartbeat set to 10 mins (for some product needs). My observation is the connectionListener.onClose() method does not get called for almost 10 mins even after the underlying rabbitMQ has died. We also do a health status check on the API and use the connectionListener.isOpen() method to determine the state of the connection. And because of this code block in the SimpleConnection class @Override public boolean isOpen() { return delegate !=

Group received messages in RabbitMQ, preferably using Spring AMQP?

江枫思渺然 提交于 2019-12-07 15:39:45
问题 I'm receiving messages from a service (S) that publishes each individual property change to an entity as a separate message. A contrived example would be an entity like this: Person { id: 123 name: "Something", address: {...} } If name and address are updated in the same transaction then (S) will publish two messages, PersonNameCorrected and PersonMoved . The problem is on the receiving side where I'm storing a projection of this Person entity and each property change causes a write to the

Automatic retry connection to broker by spring-rabbitmq

孤者浪人 提交于 2019-12-07 08:20:27
问题 I have read this fragment of docs: RabbitMQ Automatic Connection/Topology recovery Since the first version of Spring AMQP, the framework has provided its own connection and channel recovery in the event of a broker failure. Also, as discussed in Section 3.1.10, “Configuring the broker”, the RabbitAdmin will re-declare any infrastructure beans (queues etc) when the connection is re-established. It therefore does not rely on the Auto Recovery that is now provided by the amqp-client library.

Expired Message Delivery Sequence RabbitMQ

萝らか妹 提交于 2019-12-06 14:48:06
We are building a solution in which we are publishing message to a time-out queue. After TTL expiry messages are pushed to main queue for re-processing. We are setting up counter value so that messages will be tried for x no. of times for the redelivery. Solution is working fine. But the scenario is when the message on the head position is highest TTL is not expired, other messages of lower expiry will not be re-published (to main queue). Is this understanding correct ? If Yes what is the solution so that each message re-processed just after TTL. Appreciating answers / viewpoint. Thanks. If

Rabbitmq concurrent consumers in Spring boot

牧云@^-^@ 提交于 2019-12-06 10:34:34
问题 I'm using @RabbitListener annotation and SimpleRabbitListenerContainerFactory bean for parallel execution of rabbitmq messages and setting the min and max concurrent consumers in the following way : @Bean public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() { SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory(); factory.setConnectionFactory(connectionFactory()); factory.setConcurrentConsumers(MIN_RABBIT_CONCURRENT_CONSUMERS);

Spring rabbitlistner stop listening to queue using annotation syntax

浪尽此生 提交于 2019-12-06 10:04:24
A colleague and I are working on an application using Spring which needs to get a message from a RabbitMQ queue. The idea is to do this using (the usually excellent) spring annotation system to make the code easy to understand. We have the system working using the @RabbitListner annotation but we want to get a message on demand. The @RabbitListner annotation does not do this, it just receives messages when they are available. The demand is determined by the "readiness" of the client i.e. a client should "get" a message from te queue stop listing and process the message. Then determine if it is