spring-rabbit

RabbitTemplate receive messages and requeue

非 Y 不嫁゛ 提交于 2019-12-23 15:40:12
问题 My question is very similar to this one: RabbitTemplate receive and requeue Unfortunately it has been marked as answered though the answer doesn't suit my needs. I want to mimic the functionality of the Rabbit Admin UI, i.e. I want to synchronously read messages from a queue, but don't want the queue to lose them, i.e. something like having a peek. The answer here RabbitTemplate receive and requeue suggests using a listener, but in that case it'll read and requeue indefinitely. I want to get

java spring rabbit - gracefully reject a message

前提是你 提交于 2019-12-22 10:25:04
问题 I have the following listener method: @Override public void onMessage(Message message, Channel channel) { try { // do something bad :) } catch (Exception e){ try { long dt = null != message.getMessageProperties() ? message.getMessageProperties().getDeliveryTag() : 0; channel.basicReject(dt, true); } catch(IOException io) { logger.error("IO-COMMON", io); } } } The issue is basic reject doesn't work, I don't know why. How to reject it gracefully? I think that if I reject a message, it should be

java spring rabbit - gracefully reject a message

馋奶兔 提交于 2019-12-22 10:18:11
问题 I have the following listener method: @Override public void onMessage(Message message, Channel channel) { try { // do something bad :) } catch (Exception e){ try { long dt = null != message.getMessageProperties() ? message.getMessageProperties().getDeliveryTag() : 0; channel.basicReject(dt, true); } catch(IOException io) { logger.error("IO-COMMON", io); } } } The issue is basic reject doesn't work, I don't know why. How to reject it gracefully? I think that if I reject a message, it should be

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

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

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

Dynamically add new queues, bindings and exchanges as beans

会有一股神秘感。 提交于 2019-12-17 19:35:22
问题 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;

How to configure heartbeat for spring-rabbitmq

和自甴很熟 提交于 2019-12-14 03:48:42
问题 How can I configure spring-rabbitmq connection-factory <rabbit:connection-factory id="connectionFactory" host="${rabbitmq.host}" port="${rabbitmq.port:5672}" username="guest" password="guest"/> With a requested heartbeat ? 回答1: You can provide the underlying connection factory as a bean, properties set on the rabbit:connection-factory will be overridden. <rabbit:connection-factory id="connectionFactory" host="${rabbitmq.host}" port="${rabbitmq.port:5672}" username="guest" password="guest"

SpringCloud - ConfigServer - RabbitMQ - Client doesn't receive message from ConfigService

拟墨画扇 提交于 2019-12-13 17:22:24
问题 I'm trying to make a ConfigServer Remote and Client with Gitlab repository. The ConfigServer receives the notification of push through a Webhooks, but it doesn´t send the message to the client. I run a RabbitMQ with Docker, and I can see in the rabbit's console that the services are connected with it. So I don´t know what is the problem. The configServer pom file looks like: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>

Don't ack RabbitMQ messages until IntegrationFlow service activator method returns succesfully?

喜夏-厌秋 提交于 2019-12-13 03:19:43
问题 I have an integration flow defined like this: IntegrationFlows.from(Amqp.inboundAdapter(connectionFactory, "queueName") .id("id") .autoStartup(autoStartup) .concurrentConsumers(2) .maxConcurrentConsumers(3) .messageConverter(messageConverter())) .aggregate(a -> ...) .handle(serviceActivatorBean, "myMethod", e -> e.advice(requestHandlerRetryAdviceForIntegrationFlow())) .get(); Where the serviceActivatorBean is defined like this: @Component @Transactional public class ServiceActivator {