Reputation: 1437
For JMS pub/sub with a topic and two durable subscribers, in most cases when a message is sent to the topic we want the message to be consumed by both subscribers.
But in a particular scenario we may want want the message to be consumed by only a particular subscriber. Is that possible and can it be done? We are using OracleAQ with Spring Boot.
Upvotes: 0
Views: 160
Reputation: 36223
You can use message selectors.
Simply add a property to the message that you then filter in the consumer.
Producer
Message msg = ...
// Setting message properties
msg.setStringProperty("releaseYear", "1977");
Consumer
MessageConsumer consumer = session.createConsumer(queue, "releaseYear < 1980");
Read more here: https://docs.oracle.com/cd/A87860_01/doc/ois.817/a65435/jms_feat.htm#1001827
Upvotes: 0