spring-rabbit

SimpleMessageListenerContainer bulk message processing

拥有回忆 提交于 2019-12-11 09:52:12
问题 I have a stream of incoming data that is sent to RabbitMQ as individual messages. I want to send these to a service that requires a batch of messages. I need to send the request to the service when I either have a batch of 1000 messages or when 5 seconds have expired. Is this possible using SimpleMessageListenerContainer? The SimpleMessageListenerContainer supports transactions, however this won't help with the 5 second timeout. I did look at the method doReceiveAndExecute

How to use multiple vhosts in a Spring RabbitMQ project?

拟墨画扇 提交于 2019-12-11 04:38:04
问题 I've the following two Configuration classes: @Configuration @EnableRabbit @Import({ LocalRabbitConfigA.class, CloudRabbitConfigA.class }) public class RabbitConfigA { @Autowired @Qualifier("rabbitConnectionFactory_A") private ConnectionFactory rabbitConnectionFactory; @Bean(name = "admin_A") AmqpAdmin amqpAdmin() { return new RabbitAdmin(rabbitConnectionFactory); } @Bean(name = "Exchange_A") DirectExchange receiverExchange() { return new DirectExchange("Exchange_A", true, false); } } And

SimpleMessageListenerContainer shutdowntimeout

别等时光非礼了梦想. 提交于 2019-12-11 04:29:08
问题 I am using spring-rabbit-1.7.3.RELEASE.jar I have defined a SimpleMessageListenerContainer in my xml with shutdownTimeout parameter. bean id="aContainer" class="org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer"> <property name="connectionFactory" ref="rabbitConnectionFactory" /> <property name="queueNames" value="aQueue" /> <property name="adviceChain" ref="retryAdvice" /> <property name="acknowledgeMode" value="AUTO" /> <property name="shutdownTimeout" value="900000" /

spring-rabbit JSON deserialization for ArrayList contents

筅森魡賤 提交于 2019-12-11 03:32:53
问题 I am using Spring-boot with rabbitmq with JSON message serialization. Replies using the Direct-Reply-to feature cannot deserialize my classes inside the java.util.List container. Using my debugger in Jackson2JsonMessageConverter.fromMessage() , the MessageProperties states the __TypeID__ is correctly set to java.util.ArrayList . However the __ContentTypeId__ is java.lang.Object is incorrect as I would be expecting FooDto (I assume...). The exception message is: java.lang.ClassCastException:

Spring RMQ listener always use PLAIN auth even after configuring SSL properties

自古美人都是妖i 提交于 2019-12-11 01:13:34
问题 I have a spring boot application and I am trying to configure listeners to already existing queues. Following is what I configured in my application.yml file. I have also annotated my config class with @EnableRabbit and listener with @RabbitListener with appropriate configuration referring spring documentation. Please note that every property has a valid default value, I have removed them before posting them here. spring: rabbitmq: host: ${rmq_host} port: ${rmq_port} virtualHost: ${rmq

how can i get correlationId?

↘锁芯ラ 提交于 2019-12-10 18:49:27
问题 On my project(spring-rabbit..), Set fixed ReplyTo queue on template, I use convertSendAndReceive method for RPCs. I understand that mekes correlationId automatically. Can I set correlationId before using that method? Here is Template. @Bean public RabbitTemplate rabbitTemplate() { RabbitTemplate template = new RabbitTemplate(connectionFactory()); template.setMessageConverter(jsonMessageConverter()); template.setRoutingKey(AmqpConstants.JOB_QUEUE_NAME); template.setExchange(AmqpConstants.JOB

Spring AMQP Integration - Consumer Manual Acknowledgement

冷暖自知 提交于 2019-12-10 16:17:00
问题 I am testing Spring-AMQP with Spring-Integration support, I've following configuration and test: <rabbit:connection-factory id="connectionFactory" /> <rabbit:queue name="durableQ"/> <int:channel id="consumingChannel"> <int:queue capacity="2"/> <!-- Message get Acked as-soon-as filled in Q --> </int:channel> <int-amqp:inbound-channel-adapter channel="consumingChannel" queue-names="durableQ" connection-factory="connectionFactory" concurrent-consumers="1" acknowledge-mode="AUTO" /> public static

Spring rabbitlistner stop listening to queue using annotation syntax

家住魔仙堡 提交于 2019-12-10 11:07:20
问题 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

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

How to implement a round-robin queue consumer in Spring boot

青春壹個敷衍的年華 提交于 2019-12-07 22:50:01
问题 I am building a message driven service in spring which will run in a cluster and needs to pull messages from a RabbitMQ queue in a round robin manner. The implementation is currently pulling messages off the queue in a first come basis leading to some servers getting backed up while others are idle. The current QueueConsumerConfiguration.java looks like : @Configuration public class QueueConsumerConfiguration extends RabbitMqConfiguration { private Logger LOG = LoggerFactory.getLogger