A Message Consumer can be created with a "message selector" that restricts the consumption of message to those with specific properties. When creating a Message Consumer for topics, you can set a
noLocal attribute that prohibits the consumption of messages that are published over the same connection from which they are consumed.
As described in Durable Subscribers for Topics, messages published to topics are only consumed by active subscribers to the topic; otherwise the messages are not consumed and cannot be retrieved later. You can create a durable subscriber that ensures messages published to a topic are received by the subscriber, even if it is not currently running. For queues, messages remain on the queue until they are either consumed by a Message Consumer, the message expiration time has been reached, or the maximum size of the queue is reached.
See the tibjmsMsgConsumer.java sample client for a working example.
The following Session.createDurableSubscriber() method creates a durable subscriber, named
"MyDurable":
See the tibjmsDurable.java sample client for a working example.
Use the Session object's createSharedConsumer() method to create or add to a shared subscription:
cons1 and
cons2 are two shared consumers on the same subscription called
mySharedSub. If a message is published to the topic, then one of those two consumers will receive it. Note that shared consumers on a given subscription do not have to use the same session/connection.
Use the Session object's createSharedDurableConsumer() method to create or add to a shared durable subscription:
cons1 and
cons2 are two shared durable consumers on the same durable subscription called
myDurableSharedSub. If a message is published to the topic, then one of those two consumers will receive it. Note that shared durable consumers on a given subscription do not have to use the same session/connection.
See the tibemsMsgConsumer.c sample client for a working example.
The following tibemsSession_CreateDurableSubscriber function creates a durable subscriber, named
"myDurable," of type
tibemsMsgConsumer:
See the tibemsDurable.c sample client for a working example.
See the csMsgConsumer.cs sample client for a working example.
The following Session.CreateDurableSubscriber method creates a durable subscriber, named
"MyDurable":
See the csDurable.cs sample client for a working example.
A Message Listener implementation has one method, onMessage, that is called by the EMS server when a message arrives on a destination. You implement the
onMessage method to perform the desired actions when a message arrives. Your implementation should handle all exceptions, and it should not throw any exceptions.
Create an implementation of the MessageListener interface, create a
MessageConsumer, and use the
MessageConsumer object’s
setMessageListener() method to register the Message Listener with the Message Consumer:
Implement the onMessage() method to perform the desired actions when a message arrives:
See the tibjmsAsyncMsgConsumer.java sample client for a working example.
Implement an onMessage() function to perform the desired actions when a message arrives:
In another function, that creates a tibemsMsgConsumer and uses the
tibemsMsgConsumer_SetMsgListener function to create a message listener for the Message Consumer, specifying onMessage() as the callback function:
See the tibemsAsyncMsgConsumer.c sample client for a working example.
Create an implementation of the IMessageListener interface, use
Session.CreateConsumer to create a
MessageConsumer, and set the
MessageListener property on the
MessageConsumer object to register the Message Listener with the Message Consumer:
Implement the IMessageListener.OnMessage method to perform the desired actions when a message arrives:
See the csAsyncMsgConsumer.cs and
csAsyncMsgConsumerUsingDelegate.cs sample clients for working examples.