public class GSMessageConsumerImpl extends Object implements javax.jms.MessageConsumer, javax.jms.QueueReceiver, javax.jms.TopicSubscriber
javax.jms.MessageConsumer
interface.
GigaSpaces implementation of the JMS MessageConsumer Interface and the Jini RemoteEventListener.
- It holds MessageConsumer Destination, Topic or Queue - It creates the GigaSpaces OnMessageNotifyDelegator and the notify() calls the MessageListener.onMessage() method. - It supports both Synchronized and Asynchronized message consumption. One can use the method receive() for the Synchronized form, or use the NotifyDelegator together with a MessageListener implementation for the Asynchronized message receiving manner.
Modifier and Type | Field and Description |
---|---|
protected boolean |
m_closed
true if the session is closed. |
protected javax.jms.Destination |
m_dest
The destination the consumer gets its messages from
|
protected String |
m_destName
The destination name the consumer gets its messages from GERSHON FIX 25042006 - The default
class name (dest name is dummy in case the destination is null in the beginning and that
later passed to the send().
|
String |
m_durableSubscriptionName
The durable consumer subscription name.
|
protected boolean |
m_isQueue
Tells whether this is a queue or a topic consumer
|
protected GSSessionImpl |
m_session
The m_session the consumer belongs to
|
Constructor and Description |
---|
GSMessageConsumerImpl(GSSessionImpl session,
javax.jms.Destination dest,
String consumerID,
String subsriptionName,
String selector,
boolean noLocal)
Constructs a message consumer.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Cancels the onMessage notify delegator, using its Lease.cancel() if it is an Asyc operation
Also it removes the current consumer from the consumers list held by the session.
|
String |
getConsumerID()
Returns the consumer ID.
|
javax.jms.Destination |
getDestination() |
javax.jms.MessageListener |
getMessageListener()
API method.
|
String |
getMessageSelector()
API method.
|
String |
getName()
Return the durable subscription name
|
boolean |
getNoLocal() |
javax.jms.Queue |
getQueue() |
protected GSSessionImpl |
getSession()
Returns the m_session that created this consumer.
|
javax.jms.Topic |
getTopic() |
boolean |
isClosed()
Determines if the consumer is closed
|
boolean |
isDurableSubscriber()
Determines if the subscriber is durable
|
javax.jms.Message |
receive()
API method.
|
javax.jms.Message |
receive(long timeout)
API method.
|
javax.jms.Message |
receiveNoWait()
API method.
|
void |
setMessageListener(javax.jms.MessageListener listener)
This method is called by the JMS Client, it sets the MessageListener implementation and It
creates a GigaSpaces NotifyDelegator for Asynchronic messaging.
|
String |
toString() |
protected javax.jms.Destination m_dest
protected String m_destName
protected GSSessionImpl m_session
protected volatile boolean m_isQueue
protected volatile boolean m_closed
true
if the session is closed.public String m_durableSubscriptionName
public GSMessageConsumerImpl(GSSessionImpl session, javax.jms.Destination dest, String consumerID, String subsriptionName, String selector, boolean noLocal) throws javax.jms.JMSException
session
- The m_session the consumer belongs to.dest
- The destination the consumer gets messages from.subsriptionName
- The m_durableSubscriber subscription's name, if any.selector
- Selector string for filtering messages.javax.jms.IllegalStateException
- If the connection is broken.javax.jms.JMSException
- If the creation fails for any other reason.public String getMessageSelector() throws javax.jms.JMSException
getMessageSelector
in interface javax.jms.MessageConsumer
javax.jms.IllegalStateException
- If the consumer is closed.javax.jms.JMSException
public javax.jms.MessageListener getMessageListener() throws javax.jms.JMSException
getMessageListener
in interface javax.jms.MessageConsumer
javax.jms.IllegalStateException
- If the consumer is closed.javax.jms.JMSException
public void setMessageListener(javax.jms.MessageListener listener) throws javax.jms.JMSException
setMessageListener
in interface javax.jms.MessageConsumer
javax.jms.IllegalStateException
- If the consumer is closed.javax.jms.JMSException
MessageConsumer.setMessageListener(MessageListener)
public javax.jms.Message receive() throws javax.jms.JMSException
receive
in interface javax.jms.MessageConsumer
javax.jms.IllegalStateException
- If the consumer is closed, or if the connection is broken.javax.jms.JMSSecurityException
- If the requester is not a READER on the destination.javax.jms.JMSException
- If the request fails for any other reason.public javax.jms.Message receive(long timeout) throws javax.jms.JMSException
receive
in interface javax.jms.MessageConsumer
timeout
- This call blocks until a message arrives, the timeout expires, or this message
consumer is closed. The jms client may select A timeout
of zero,
that means it never expires, and the call blocks indefinitely. It is the same
as the Space timeout which its value to Long.MAX_VALUE Regarding the space
timeout, it means how long the client is willing to wait for a transactionally
proper matching entry. A timeout of IJSpace.NO_WAIT
means to wait
no time at all; this is equivalent to a wait of zero (in space only, not in
jms).javax.jms.IllegalStateException
- If the consumer is closed, or if the connection is broken.javax.jms.JMSSecurityException
- If the requester is not a READER on the destination.javax.jms.JMSException
- If the request fails for any other reason.public javax.jms.Message receiveNoWait() throws javax.jms.JMSException
receiveNoWait
in interface javax.jms.MessageConsumer
javax.jms.IllegalStateException
- If the consumer is closed, or if the connection is broken.javax.jms.JMSSecurityException
- If the requester is not a READER on the destination.javax.jms.JMSException
- If the request fails for any other reason.public boolean isClosed()
true
if the consumer is closedpublic void close() throws javax.jms.JMSException
close
in interface javax.jms.MessageConsumer
javax.jms.JMSException
MessageConsumer.close()
public String getConsumerID()
protected GSSessionImpl getSession()
public String getName()
null
if this is a non-durable
subscriberpublic boolean isDurableSubscriber()
true
if the subscriber is durablepublic javax.jms.Queue getQueue() throws javax.jms.JMSException
getQueue
in interface javax.jms.QueueReceiver
javax.jms.JMSException
QueueReceiver.getQueue()
public boolean getNoLocal() throws javax.jms.JMSException
getNoLocal
in interface javax.jms.TopicSubscriber
javax.jms.JMSException
TopicSubscriber.getNoLocal()
public javax.jms.Topic getTopic() throws javax.jms.JMSException
getTopic
in interface javax.jms.TopicSubscriber
javax.jms.JMSException
TopicSubscriber.getTopic()
public javax.jms.Destination getDestination() throws javax.jms.JMSException
javax.jms.JMSException
Copyright © GigaSpaces.