Shared subscriptions

WebSphere® Application Server version 9.0 supports sharing of both durable and nondurable subscriptions. Shared subscription, which is introduced in JMS 2.0 specification, is used to share a single subscription among multiple consumers, with only one of the consumers receiving a publication at any point in time. Shared subscriptions are basically used for sharing the load among multiple consumers, and are identified by the name and client identifier.

For more information about shared nondurable and durable subscriptions, refer to the sections 8.3.2 and 8.3.4 in the JMS 2.0 specification document.
Note: Shared durable subscription feature was available in the earlier versions of WebSphere Application Server, and shared nondurable subscription feature is introduced in WebSphere Application Server version 9.0.

The following example shows the code sample of creating a shared durable and shared nondurable subscription:

Create a shared durable subscription

ConnectionFactory connectionFactory;
Connection connection;
Session session;
MessageConsumer consumer;
Topic topic;
String sharedDurableSubName;
...
connection = connectionFactory.createConnection();


// Note: client ID is not mandatory for shared durable subscriptions
connection.setClientID("myClient"); 
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
topic = session.createTopic("sharedTopic");
consumer = ((ImaSubscription)session).createSharedDurableConsumer(topic, sharedDurableSubName);

Create a shared non-durable subscription

ConnectionFactory connectionFactory;
Connection connection;
Session session;
MessageConsumer consumer;
Topic topic;
String sharedSubName;
...
connection = connectionFactory.createConnection();

connection.setClientID("myClient"); 
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
topic = session.createTopic("sharedTopic");
consumer = ((ImaSubscription)session).createSharedConsumer(topic, sharedSubName);
Note: Shared durable and shared non-durable subscription can be created using the following selection criteria:
consumer = session.createSharedConsumer(topic, sharedSubName, selector);
consumer = session.createSharedDurableConsumer(topic, sharedDurableSubName, selector);

指出主題類型的圖示 概念主題



時間戳記圖示 前次更新: July 9, 2016 11:11
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=cjt0015a_
檔名:cjt0015a_.html