spring-amqp

Spring AMQP - Message re queuing using dead letter mechanism with TTL

有些话、适合烂在心里 提交于 2019-12-22 00:25:06
问题 Its like " Houston we have a problem here " where I need to schedule/delay a message for 5 minutes after it fails on the first attempt to process an event. I have implemented dead letter exchange in this scenario. The messages on failing, route to the DLX --> Retry Queue and comes back to work queue after a TTL of 5 minutes for another attempt. Here is the configuration I am using: public class RabbitMQConfig { @Bean(name = "work") @Primary Queue workQueue() { return new Queue(WORK_QUEUE,

How to start, stop and reconnect spring rabbitmq listener containers and their connections?

本秂侑毒 提交于 2019-12-21 02:41:42
问题 I've an internet connection where the exit gateway periodically changes. I'm getting an event or callback notification to my spring application some seconds before this happens. I would like to stop my rabbit consumers and connections then and connect again after some seconds (when my network connection is back). I'm using the annotation based approach of spring amqp but i could also switch to another kind of implementation. I know that spring-amqp is doing a reconnect for me but i would like

Receive and Send Java Objects with Spring AMQP

落爺英雄遲暮 提交于 2019-12-20 06:35:06
问题 I want to implement Spring AMQP example for sending and receiving Java Objects using listener. I tried this: Send Java Object ConnectionFactory connectionFactory = new CachingConnectionFactory("localhost"); AmqpAdmin admin = new RabbitAdmin(connectionFactory); admin.declareBinding(BindingBuilder.bind(new Queue(QUEUE_PROCESSING_TRANSACTION, false)).to(new TopicExchange(EXCHANGE_PROCESSING)).with(ROUTING_KEY_PROCESSING_TRANSACTION)); AmqpTemplate template = new RabbitTemplate(connectionFactory)

spring amqp rabbit max consumer connection retries

醉酒当歌 提交于 2019-12-20 06:17:54
问题 I am trying to establish the max number of retries from my app to rabbit broker. I have the retry interceptor, @Bean public RetryOperationsInterceptor retryOperationsInterceptor() { return RetryInterceptorBuilder.stateless() .maxAttempts(CommonConstants.MAX_AMQP_RETRIES) .backOffOptions(500, 2.0, 3000) .build(); } and this is used inside listener container, container.setAdviceChain(new Advice[]{retryOperationsInterceptor()}); However, after a couple of retries, the consumer attempts

DLX in rabbitmq and spring-rabbitmq - some considerations of rejecting messages

旧城冷巷雨未停 提交于 2019-12-20 05:38:32
问题 I did read this reference: https://www.rabbitmq.com/dlx.html, however it doesn't resolve my doubts, namely: In case of accepting message there is no problem - spring-rabbitmq send ack and everthing is fine, DLX doesn't know about acked message. The problem is in case rejecting answer, namely what about throwing MessageConverterException ? This message is removed or moved to DLX ? And what about in case other exception ? For example Exception ? It is removed/requeued/moved to DLX ? Edit after

Large RabbitMQ message in Slow network

吃可爱长大的小学妹 提交于 2019-12-20 03:05:38
问题 I am using RabbitMQ with Spring AMQP large message (>100MB, 102400KB) small bandwidth (<512Kbps) low heartbeat interval (10 seconds) single broker It will take >= 200*8 seconds to consume the message, which is more than my heartbeat interval. From https://stackoverflow.com/a/42363685/418439 If the message transfer time between nodes (60seconds?) > heartbeat time between nodes, it will cause the cluster to disconnect and the loose the message Will I also face the disconnection issue even I am

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

跟風遠走 提交于 2019-12-19 10:39:06
问题 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

RabbitMQ Integration Test and Threading

杀马特。学长 韩版系。学妹 提交于 2019-12-19 06:41:31
问题 I have written a RabbitMQ consumer by implementing the MessageListener interface and setting up a SimpleMessageListenerContainer. Its working well when I test it manually. Now I would like to write an integration test that: Creates a message Pushes the message to my RabbitMQ server Waits while the message is consumed by my MessageListener implementation Test makes some asserts once everything is done However, since my MessageListener is running in a separate thread, it makes unit testing

RabbitMQ Integration Test and Threading

☆樱花仙子☆ 提交于 2019-12-19 06:40:25
问题 I have written a RabbitMQ consumer by implementing the MessageListener interface and setting up a SimpleMessageListenerContainer. Its working well when I test it manually. Now I would like to write an integration test that: Creates a message Pushes the message to my RabbitMQ server Waits while the message is consumed by my MessageListener implementation Test makes some asserts once everything is done However, since my MessageListener is running in a separate thread, it makes unit testing

How to write an integration test for @RabbitListener annotation?

送分小仙女□ 提交于 2019-12-18 08:09:09
问题 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? 回答1: With the help