NonStop JMS User's Manual (H06.03+, J06.03+, NonStop JMS 3.0+)
NSJMS and JMS Client Applications
NonStop Server for Java Message Service User’s Manual—522356-006
4-10
Receiving Messages
This code fragment shows the use of instanceof when pulling the contents from a 
TextMessage:
if (inMessage instanceof TextMessage){
 String replyString =((TextMessage)inMessage).getText();
 .
 .
 .
} else {
 System.out.println("Reply message was not a TextMessage");
}
Receiving Messages from a Topic
To receive a message from a topic, you create a TopicSubscriber using the 
createSubscriber() method. This method creates TopicSubscribers as either non-
durable or durable subscribers.
Non-durable Subscribers
These subscribers only receive messages that are published on a chosen topic while 
the subscriber is active.
To create a non-durable subscriber use the createSubscriber() method for the 
session object. For example:
TopicSubscriber subscriber = session.createSubscriber(topic);
Non-durable subscribers automatically terminate themselves when their close() 
method is called.
Durable Subscribers
These subscribers receive all messages published on a topic, including messages 
published while the subscriber is inactive.
A durable subscriber registers a durable subscription with a unique identity that is 
retained by the NSJMS. Subsequent subscriber objects with the same identity resume 
the subscription in the same state as left by the previous subscriber. If a durable 
subscription has no active subscriber, the NSJMS retains the subscription's messages 
until they are received by the subscription or until they expire. 
To establish a unique identity for a durable subscriber specify:
A client ID for the connection.
A topic and a subscription name for the subscriber.
The client ID is set by calling the setClientID() method for the connection object. 
For example, connection.setClientID ("client_ID_01");
The client ID must be set before creating the durable subscription. To create a durable 
subscriber use the createDurableSubscriber() method for the session object. 










