Pand005
Pand005

Reputation: 1175

How to consume messages selectively from Spring AMQP?

In the queue I have pushed 10K objects. Timestamp is one of the attribute in object. So, how can I write a consumer code using spring amqp?

can anyone help me on this.

Upvotes: 1

Views: 561

Answers (1)

Gary Russell
Gary Russell

Reputation: 174484

AMQP, unlike JMS, has no notion of message selection for consumers. One solution is to use a topic exchange and set the routing key - let's say consumer 1 binds his queue to the exchange with foo.bar a second one binds with foo.baz; and a third binds with foo.*. The third will get all messages (with routing keys starting with foo.); the others will only get messages with their respective keys.

A direct exchange could also be used; it requires a complete match on the routing key.

You should probably work through all the RabbitMQ tutorials to understand the different exchange types before asking more questions here.

Upvotes: 2

Related Questions