Reputation: 23
I am using spring amqp multi thread environment and have multiple channels on one mq connection shared between these threads. Messages with various topics are published on these channels. Need to maintain ordering of messages having same topic and to achieve this I need to publish them to same channel each time. How can I achieve this? Does spring provide some provision to choose a fixed channel among available list of channels?
Upvotes: 0
Views: 34
Reputation: 121542
You probably need to look into a dedicated CachingConnectionFactory
for your RabbitTemplate
with size 1
for the pool of channels.
Another candidate is a ThreadChannelConnectionFactory
, but you need to ensure that all your producers send messages to the same thread where such a RabbitTemplate
instance would reuse the mentioned channel attached to that thread.
See more info in docs: https://docs.spring.io/spring-amqp/reference/amqp/connections.html
Upvotes: 0