spring-amqp

RabbitMQ - Send message to a particular consumer in a queue

南笙酒味 提交于 2019-12-06 08:16:01
问题 This is the scenario - There are multiple app servers. Browser can connect via websocket to any app server. The app servers (consumers) are all listening on a particular queue. As soon as a web socket connection is received, the particular app server binds the queue with a routing key {userId} to a direct exchange. I want a message sent to the direct exchange with the routing key {userId} to be received by only the particular app server where the binding has occured. Is a direct exchange the

Adding multiple listeners which will listen to different RabbitMQ queue not working

我的未来我决定 提交于 2019-12-06 07:23:59
问题 I hava following spring xml configuration <bean id="connectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory"> <constructor-arg value="xxxxxxxx"/> <property name="username" value="xxxxx"/> <property name="password" value="xxxxx"/> <property name="channelCacheSize" value="25"/> <property name="virtualHost" value="/"/> <property name="port" value="3453"/> </bean> <rabbit:template id="tutorialTemplate" connection-factory="connectionFactory"/> <!-- 1st queue -

Spring AMQP exception handling basics

喜欢而已 提交于 2019-12-06 06:27:51
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 AmqpRejectAndDontRequeueException at that point? I'm wondering about the best practice for this. Thanks. There are

Spring AMQP StatefulRetryOperationsInterceptor not used

匆匆过客 提交于 2019-12-06 05:45:33
问题 I am trying configure spring amqp to only retry a message a defined amount of times. Currently a message that fails e.g. because of a DataIntegrityViolationException is redelivered indefinitely. According to the documentation here I came up with the following configuration @Bean public StatefulRetryOperationsInterceptor statefulRetryOperationsInterceptor() { return RetryInterceptorBuilder.stateful() .backOffOptions(1000, 2.0, 10000) // initialInterval, multiplier, maxInterval .maxAttempts(3)

SpringAMQP RabbitMQ how to send directly to Queue without Exchange

折月煮酒 提交于 2019-12-06 03:48:08
I'm using SpringAMQP with Rabbit template. How to send messages directly to Queues omitting Exchange? How can i do it? How can i do it? You can't; publishers don't know about queues; just exchanges and routing keys. However, all queues are bound to the default exchange ( "" ) with the queue name as its routing key. If you are using Spring AMQP's RabbitTemplate , it is configured to publish to the default exchange by default, so you can use convertAndSend("myQueue", "foo")` Or even... template.setDefaultRoutingKey("myQueue"); then template.convertAndSend("foo"); or template.send(aMessage); 来源:

Group received messages in RabbitMQ, preferably using Spring AMQP?

会有一股神秘感。 提交于 2019-12-05 19:57:55
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 database. So in this example there would be two writes to the database but if I could batch messages for

Spring RabbitMQ tutorial results in Connection Refused error

99封情书 提交于 2019-12-05 19:01:16
I'm an experienced Java programmer and am trying out Spring Rabbit MQ for the first time. I followed the messaging-rabbitMQ tutorial exactly using Maven. http://spring.io/guides/gs/messaging-rabbitmq/ I am running on CentOS as a user account. When I ran the application at the very end of the tutorial with java -jar target/gs-messaging-rabbitmq-0.1.0.jar , I got the following Connection Refused error. Can someone help? prompt> java -jar target/gs-messaging-rabbitmq-0.1.0.jar . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | |

Is Spring-AMQP re-queue message count JVM based?

泪湿孤枕 提交于 2019-12-05 18:43:52
I was poking around the rabbitmq documentation, and it seems that rabbitmq does not handle message redelivery count. If I were to manually ACK/NACK messages, I would need to either keep the retry count in memory (say, by using correlationId as the unique key in a map), or by setting my own header in the message, and redelivering it (thus putting it at the end of the queue) However, this is a case that spring handles. Specifically, I am referring to RetryInterceptorBuilder.stateful().maxAttempts(x). Is this count specific to a JVM though, or is it manipulating the message somehow? For example,

Automatic retry connection to broker by spring-rabbitmq

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 11:48:46
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. Spring AMQP now uses the 4.0.x version of amqp-client, which has auto recovery enabled by default. Spring

spring amqp rabbitmq MessageListener not working

烈酒焚心 提交于 2019-12-05 10:33:14
问题 I am trying to use rabbitmq using spring amqp, below is my configuration. <rabbit:connection-factory id="rabbitConnectionFactory" port="${rabbitmq.port}" host="${rabbitmq.host}" /> <rabbit:admin connection-factory="rabbitConnectionFactory" /> <rabbit:queue name="${rabbitmq.import.queue}" /> <rabbit:template id="importAmqpTemplate" connection-factory="rabbitConnectionFactory" queue="${rabbitmq.import.queue}" /> <beans:bean id="importExchangeMessageListener" class="com.stockopedia.batch