Implementing JMS topic publisher
Let's say that we want to inform a bunch of applications when a new course is added. Such use cases can be best implemented by a JMS topic. A topic can have many subscribers. When a message is added to the topic, all subscribers are sent the same message. This is unlike a queue, where only one queue listener gets a message.
Steps to publish messages to a topic and subscribe for messages are very similar to those for a queue, except for the different classes, and in some cases, different method names.
Let's implement a topic publisher, which we will use when the message for adding a course is successfully handled in the onMessage method of the listener class implemented in CourseQueueReceiver.
Create CourseTopicPublisher ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access