Show TOC

Using Durable SubscriptionsLocate this document in the navigation structure

Context

When a topic subscriber is not active, messages that were sent during its period of inactivity will not be delivered to it when it becomes active again. If you want to be sure you receive all messages published to a topic, no matter if your subscriber has been continuously active, you can create a durable subscriber.

Using durable subscriptions may lead to higher processing overheads. Remember to unsubscribe your durable subscribers once you no longer need them. The JMS Provider keeps all the messages that durable subscribers have not yet consumed, so unneeded durable subscribers can waste a significant amount of resources and degrade JMS Provider performance.

Procedure


  1. Create a durable subscription:

    ...
    
    Topic topic;
    
    String subscription_name = "my_sub";
    
    ...
    
    TopicSubscriber topicSubscriber = topicSession.createDurableSubscriber(topic, subscription_name);
    
                         
  2. Inactivate the durable subscription:

    topicSubscriber.close();
    
                         
  3. Delete the durable subscription and unsubscribe the subscription name:

    topicSession.unsubscribe(subscription_name);