Show TOC

Procedure documentationUsing Durable Subscriptions Locate this document in the navigation structure

 

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:

    Syntax Syntax

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

    Syntax Syntax

    1. topicSubscriber.close();
      
    End of the code.
  3. Delete the durable subscription and unsubscribe the subscription name:

    Syntax Syntax

    1. topicSession.unsubscribe(subscription_name);
      
    End of the code.