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 ...