The Pub/Sub messaging model sends and receives messages using the Publish-Subscribe method.
With the Pub/Sub messaging model, the sending client (producer) that creates and sends the messages is called the publisher. Also, the client (consumer) that receives the messages is called the subscriber.
The messages sent from the publisher are registered in a destination called the topic. The messages registered in the topic are delivered to one or multiple subscribers that applied to that topic for a delivery.
The following figure shows the flow of messages in the Pub/Sub messaging model.
Figure 7-6 Flow of messages in the Pub/Sub messaging model
The messages are sent from the publisher and registered in the topic. In the figure, subscriber1 is registered in topic1, and subscriber2 and subscriber3 are registered in topic2. At this time, message1 and message2 registered in topic1 are delivered to subscriber1, and message3 registered in topic2 is delivered to subscriber2 and subscriber3.
The features of the Pub/Sub messaging model are as follows:
Only the subscriber that was running when the message was registered can receive the message registered in the topic. A normal subscriber cannot receive messages that were registered during the period when the subscriber was stopped.
On the other hand, by making the subscriber persistent, even the messages registered during the period when the subscriber was stopped, can be received. A subscriber that is made persistent is called the persistence subscriber.
The messages in the topic where the persistence subscriber is registered are not deleted until one of the following statuses is reached:
When you use a persistence subscriber, register an identifier and name specific to that subscriber. The registered information is stored by CJMSP Broker. The messages registered when the persistence subscriber is stopped are delivered to the subscriber with the registered identifier and name when the subscriber is restarted.
The following figure shows the flow of sending and receiving messages when the persistence subscriber is used.
Figure 7-7 Flow of sending and receiving messages when the persistence subscriber is used
The following points describe the flow of sending and receiving messages when the persistence subscriber is used. Note that the numbers in the description correspond to the numbers in the figure.
To cancel the specified persistence subscriber, use one of the following methods:
For details on the cjmsicmd destroy dur command, see cjmsicmd destroy dur (Destroying the persistence subscribers) in the uCosminexus Application Server Command Reference Guide.
If you use the unsubscribe method, you can cancel the status of the topic stored for the subscriber. However, do not use this method at the following times:
Note that when the persistence subscriber is created by a session with acknowledgement mode CLIENT_ACKNOWLEDGE, the message remains in the destination if the unsubscribe method is executed when the message receipt has not been confirmed. To avoid this situation, when you want to execute the unsubscribe method, first execute the cjmsicmd purge dur command to delete all the messages associated with the persistence subscriber.