spring-amqp

Rabbitmq: Unacked message not going away after broker restart

微笑、不失礼 提交于 2019-12-11 02:31:08
问题 We have observed the following behavior of RabbitMQ and are trying to understand if it is correct and how to resolve it. Scenario: A (persistent) message is delivered into a durable queue The (single) Consumer (Spring-AMQP) takes the message and starts processing => Message goes from READY to UNACK Now the broker is shut down => Client correctly reports "Channel shutdown" The consumer finishes the processing, but can not acknowledge the message as the broker is still down Broker is started

Jackson configuration to consume list of records in rabbitmq

 ̄綄美尐妖づ 提交于 2019-12-11 02:27:19
问题 I am using spring boot amqp in which I will be consuming a list of Employee objects from a queue. My listener method looks like this: @RabbitListener(queues = "emp_queue") public void processAndPortEmployeeData(List<Employee> empList) { empList.forEach(emp -> { some logic }) } However, when I try to consume the message, I get a class cast exception: For some reason, I'm getting a LinkedHashMap. Caused by: java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to com.integration

RabbitTemplate receive and requeue

元气小坏坏 提交于 2019-12-10 21:37:24
问题 I would like to receive messages from a queue an immediately dequeue them, in fact I would like to mimic the behaviour of the rabbitMQ admin console which can receive a message and requeue it. So my question is how to do this? At first I was trying to make a clone of the message and re-send them, but it seems that the rabbitTemplate is not able to send messages directly to a queue and sending them to an exchange is not an option because it could be possible that multiple queues will receive

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

AMQP Spring Integration error handling

╄→尐↘猪︶ㄣ 提交于 2019-12-10 17:53:40
问题 I've got an integration flow that looks like the following: @Bean public IntegrationFlow auditFlow(@Qualifier("eventLoggingConnectionFactory") ConnectionFactory connectionFactory, @Qualifier("writeChannel") MessageChannel messageChannel, @Qualifier("parseErrorChannel") MessageChannel errorChannel) { return IntegrationFlows .from(Amqp.inboundAdapter(connectionFactory, auditQueue) .errorChannel(errorChannel) .concurrentConsumers(numConsumers) .messageConverter(new MongoMessageConverter())) //

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

How to set the consumer-tag value in spring-amqp

天大地大妈咪最大 提交于 2019-12-10 15:46:07
问题 I am trying to update the consumer-tag to be more informative than the randomly generated string. We have a pattern which we use that includes hostname + identifier + randomized string. This works fine in our other services (ie: NodeJS with ampqlib ) because they provide a mechanism to pass in this value. However, for our Java services, we use spring-amqp and it looks like there is no way to pass in a consumer-tag value. I took a look at BlockingQueueConsumer and it is currently hard-coded to

Using @RabbitListener with Jackson2JsonMessageConverter

给你一囗甜甜゛ 提交于 2019-12-10 15:30:45
问题 I have spent the last little while trying to get it so that my handler that is registered using @RabbitListener will have the message converted with the Jackson2JsonMessageConverter. Unfortunately no matter what configuration setup I try only the SimpleMessageConverter is used. @Component @Slf4j public class TestQueueListener { @RabbitListener(queues = "#{@allQueue}") public void processMessage(String data) { log.trace("Message received: {}", data); } @RabbitListener(queues = "#{@invokeQueue}

Spring AMQP single consumer parallelism with prefetch

谁说我不能喝 提交于 2019-12-10 11:36:38
问题 We have a project that's using Spring-AMQP to consume messages from our RabbitMQ broker. We would like to increase the concurrency on the consuming side so that multiple worker threads can process messages in parallel. I began by reading the documentation for the native RabbitMQ client, and that lead me to a design of using a single consumer, and a prefetch count > 1 to control for parallelism. Using the RabbitMQ client directly, this seems quite natural. The handleDelivery method of the

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