Using Spring Integration and AMQP, can I create Pub-Sub groups of Competing Consumers?

237 views Asked by At

I'd like to create a setup like in the picture below:

enter image description here

Can this be done with Spring Integration's support for AMQP? I.e. can the communication channels in the picture be AMQP? The goal is so that:

  1. Each component in the picture can be a separate server.
  2. I can scale up each consumer group.
  3. Only one worker from each consumer group processes the message.
  4. Each consumer group receives each message.

I looked at the documentation, but am not sure if the two AMQP Message Channel implementations that SI provides (point-to-point and publish/subscribe) will do the trick here. In particular, would the point-to-point channel work like a regular Direct Channel, i.e. support multiple endpoints, only one of which receives each message?

Many thanks!

1

There are 1 answers

0
Gary Russell On BEST ANSWER

Replace the pub-sub channel with an outbound-channel-adapter that publishes to a fanout exchange.

Bind 2 queues to the fanout exchange; each will get a copy of the message.

Use inbound-channel-adapters for each of your consumers, each listening to the appropriate queue; the two groups of consumers will compete for their messages.