When using EMS topic based communication; by default, if a message is published to a topic and one or more subscribers to that topic are currently offline (not active); they won’t receive the message as message won’t persist in the EMS Server. However, If persistence of messages published to a topic is required; TIBCO EMS provides option for this by setting the subscriber as “durable”.
In this post; I will explain in detail about durable subscribers as well as an example scenario in which messages are persisted for a durable subscriber currently offline.
What is TIBCO EMS Durable Subscriber?
Durable subscribers to a EMS topic are those subscribers which are entitled to receive a message published to a topic once they are alive and ready to consume; even if they were not active when the message was published by the publisher to that topic.
If a message is sent to a topic which has at least one durable subscriber; message will be stored/ persisted by the EMS Server till the time durable subscribers have retrieved the message or the expiration time for the message has reached.
Example of using durable Subscribers in a TIBCO BW Project
To further shed the light on usage of durable subscribers; let’s consider an example in which a publishing TIBCO BW process sends a simple message to a topic “topic.durable.test”. This topic has two subscribers in the form of two processes—ProcessA and ProcessB both acting as durable subscribers so that a message published to the topic is persisted in EMS Server till the time both of these processes have subscribed/consumed the message.
The process which is sending the messages to this topic is as shown below with a JMS Topic publisher activity and nothing much fancy:
Make sure that you have already crated the topic in your EMS Server using the below command in EMS administration tool:
create topic topic.durable.test
Now in order to show the usage of durable subscription; I have created two subscriber processes–ProcessA and ProcessB as shown below:
Make sure that you check the Durable Subscription checkbox and specify a Subscription Name:
The other process (ProcessB) is similar to ProcessA and that process is also subscribing to the same topic in durable mode:
Now if you load these processes in designer tester and then enter the command “show durables” in the EMS administration tool; you can see the subscriptions as shown below:
Now, let’s run the process “SendMessage” and load only one subcriber process “ProcessA” while keeping ProcessB in offline/inactive state.
As you can see below; after the message is sent to the topic by SendMessage process; ProcessA successfully retrieves the message by using JMS Topic subscriber activity.
However, we know that we have another durable subscriber for the same topic which does have a subscription but is currently inactive (ProcessB). If you check in the EMS administration tool by using the command “show topic topic.durable.test”, you will observe that due to durable nature of the subscriber; there is a pending message still residing in the topic, waiting for the other subscriber to get alive and consume it:
Note that if the subscriber wasn’t durable; the message would have been discarded and only the active subscriber would have consumed it.
what if the topic has a property set as persistent and there is no expiration set, then it doesn’t need any durables and the message will be stored in EMS disk. Is this right?
Pingback: Difference Between TIBCO EMS Queues And Topics