Create durable subscribers

 

Durable subscribers cannot be configured with a direct connection to a broker.

Creating a durable subscriber is similar to creating a non-durable subscriber, but also provide a name that uniquely identifies the subscriber:

// Create a durable subscriber, supplying a uniquely-identifying name
TopicSubscriber sub = session.createDurableSubscriber( topic, "D_SUB_000001" );

Non-durable subscribers automatically deregister themselves when their close() method is called (or when they fall out of scope). However, if you want to terminate a durable subscription, explicitly notify the system. To do this, use the session's unsubscribe() method and pass in the unique name that created the subscriber:

// Unsubscribe the durable subscriber created above
session.unsubscribe( "D_SUB_000001" );

A durable subscriber is created at the queue manager specified in the MQTopicConnectionFactory queue manager parameter. If there is a subsequent attempt to create a durable subscriber with the same name at a different queue manager, a new and completely independent durable subscriber is returned.


uj24790_