Package org.objectweb.joram.client.jms
Class MessageConsumerListener
- java.lang.Object
-
- org.objectweb.joram.client.jms.MessageConsumerListener
-
- All Implemented Interfaces:
ReplyListener
- Direct Known Subclasses:
MultiSessionConsumer,SingleSessionConsumer
abstract class MessageConsumerListener extends Object implements ReplyListener
This class listens to replies asynchronously returned by the user proxy for a message consumer.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classMessageConsumerListener.ReceiveStatusprotected static classMessageConsumerListener.StatusStatus of the message consumer listener.
-
Field Summary
Fields Modifier and Type Field Description private static booleandebugprivate StringdestNameprivate booleandurableprivate intlistenerPositionprivate ArrayList<MessageListener>listenersprivate static org.objectweb.util.monolog.api.Loggerloggerprivate intmessageCountThe number of messages which are in queue (Session.qin) waiting for being consumed.private Vector<String>messagesToAckprivate intqueueMessageReadMaxprivate booleanqueueModeprivate intreceiveStatusThe receive status of this message listener: - WAIT_FOR_REPLY if a reply is expected from the destination - CONSUMING_REPLY if a reply is being consumed and no new request has been sentprivate intrequestIdThe identifier of the subscription request.private RequestMultiplexerrmprivate Stringselectorprivate intstatusprivate StringtargetNameprivate inttopicAckBufferMaxprivate inttopicActivationThresholdprivate booleantopicMsgInputPassivatedIndicates whether the topic message input has been passivated or not.private inttopicPassivationThresholdprivate booleanwaitingMessagesBrokerSideThis attribute indicates that there are still pending messages on the broker for this subscription.
-
Constructor Summary
Constructors Constructor Description MessageConsumerListener(boolean queueMode, boolean durable, String selector, String destName, String targetName, MessageListener listener, int queueMessageReadMax, int topicActivationThreshold, int topicPassivationThreshold, int topicAckBufferMax, RequestMultiplexer reqMultiplexer)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) voidack(String msgId, int ackMode)private voidacknowledge(int threshold)protected voidactivateListener(Message msg, MessageListener listener, int ackMode)(package private) voidactivateMessageInput()Activate the subscription server side.(package private) voidaddMessageListener(MessageListener messageListener)protected abstract booleancheckSessionThread()voidclose()Called by Session.private voiddecreaseMessageCount(int ackMode)Decrease the message count.voiderrorReceived(int requestId, org.objectweb.joram.shared.client.MomExceptionReply exc)StringgetDestName()MessageListenergetMessageListener()intgetMessageListenersSize()private MessageListenergetNextlistener()booleangetQueueMode()protected intgetStatus()StringgetTargetName()booleanisClosed()voidonMessage(Message msg, int ackMode)Called by Session (standard JMS, mono-threaded)abstract voidonMessage(Message msg, MessageListener listener, int ackMode)(package private) voidpassivateMessageInput()Passivate the subscription server side.abstract voidpushMessages(org.objectweb.joram.shared.client.ConsumerMessages cm)Pushes the received messages.(package private) booleanremoveMessageListener(MessageListener messageListener)voidreplyAborted(int requestId)booleanreplyReceived(org.objectweb.joram.shared.client.AbstractJmsReply reply)Called by RequestMultiplexer.private voidsetReceiveStatus(int s)protected voidsetStatus(int status)(package private) voidstart()Called by Session.private voidsubscribe(String[] toAck, int msgCount)
-
-
-
Field Detail
-
debug
private static final boolean debug
- See Also:
- Constant Field Values
-
logger
private static final org.objectweb.util.monolog.api.Logger logger
-
queueMode
private boolean queueMode
-
durable
private boolean durable
-
selector
private String selector
-
destName
private String destName
-
targetName
private String targetName
-
requestId
private volatile int requestId
The identifier of the subscription request.
-
status
private int status
-
messageCount
private volatile int messageCount
The number of messages which are in queue (Session.qin) waiting for being consumed. TODO (AF): Always used from synchronized block, removes volatile.
-
receiveStatus
private volatile int receiveStatus
The receive status of this message listener: - WAIT_FOR_REPLY if a reply is expected from the destination - CONSUMING_REPLY if a reply is being consumed and no new request has been sent
-
topicMsgInputPassivated
private boolean topicMsgInputPassivated
Indicates whether the topic message input has been passivated or not.
-
waitingMessagesBrokerSide
private boolean waitingMessagesBrokerSide
This attribute indicates that there are still pending messages on the broker for this subscription. If no new messages arrive, these messages may not be delivered.
-
queueMessageReadMax
private int queueMessageReadMax
-
rm
private RequestMultiplexer rm
-
topicActivationThreshold
private int topicActivationThreshold
-
topicPassivationThreshold
private int topicPassivationThreshold
-
topicAckBufferMax
private int topicAckBufferMax
-
listeners
private ArrayList<MessageListener> listeners
-
listenerPosition
private int listenerPosition
-
-
Constructor Detail
-
MessageConsumerListener
MessageConsumerListener(boolean queueMode, boolean durable, String selector, String destName, String targetName, MessageListener listener, int queueMessageReadMax, int topicActivationThreshold, int topicPassivationThreshold, int topicAckBufferMax, RequestMultiplexer reqMultiplexer)
-
-
Method Detail
-
getDestName
public final String getDestName()
-
getStatus
protected final int getStatus()
-
setStatus
protected void setStatus(int status)
-
setReceiveStatus
private void setReceiveStatus(int s)
-
decreaseMessageCount
private void decreaseMessageCount(int ackMode) throws JMSExceptionDecrease the message count. Synchronized with the method replyReceived() that increments the messageCount += cm.getMessageCount();- Throws:
JMSException
-
start
void start() throws JMSExceptionCalled by Session.- Throws:
JMSException
-
subscribe
private void subscribe(String[] toAck, int msgCount) throws JMSException
- Throws:
JMSException
-
checkSessionThread
protected abstract boolean checkSessionThread()
- Returns:
- true if the currentThread is the SessionThread.
-
close
public void close() throws JMSExceptionCalled by Session.- Throws:
JMSException
-
acknowledge
private void acknowledge(int threshold)
-
replyReceived
public boolean replyReceived(org.objectweb.joram.shared.client.AbstractJmsReply reply) throws AbortedRequestExceptionCalled by RequestMultiplexer.- Specified by:
replyReceivedin interfaceReplyListener- Returns:
- whether the request must be aborted or not.
- Throws:
AbortedRequestException
-
pushMessages
public abstract void pushMessages(org.objectweb.joram.shared.client.ConsumerMessages cm) throws JMSExceptionPushes the received messages. Currently two behaviors: 1- SingleSessionConsumer pushes the message in a single session (standard JMS) 2- MultiSessionConsumer pushes the message in several session (from a session pool)- Parameters:
cm-- Throws:
JMSException
-
replyAborted
public void replyAborted(int requestId)
- Specified by:
replyAbortedin interfaceReplyListener
-
errorReceived
public void errorReceived(int requestId, org.objectweb.joram.shared.client.MomExceptionReply exc)- Specified by:
errorReceivedin interfaceReplyListener
-
isClosed
public boolean isClosed()
-
getMessageListener
public final MessageListener getMessageListener()
-
getQueueMode
public final boolean getQueueMode()
-
getTargetName
public final String getTargetName()
-
activateListener
protected void activateListener(Message msg, MessageListener listener, int ackMode) throws JMSException
- Throws:
JMSException
-
onMessage
public abstract void onMessage(Message msg, MessageListener listener, int ackMode) throws JMSException
- Throws:
JMSException
-
addMessageListener
void addMessageListener(MessageListener messageListener)
-
removeMessageListener
boolean removeMessageListener(MessageListener messageListener)
-
getMessageListenersSize
public int getMessageListenersSize()
-
getNextlistener
private MessageListener getNextlistener()
-
onMessage
public void onMessage(Message msg, int ackMode) throws JMSException
Called by Session (standard JMS, mono-threaded)- Throws:
JMSException
-
ack
void ack(String msgId, int ackMode) throws JMSException
- Throws:
JMSException
-
activateMessageInput
void activateMessageInput() throws JMSExceptionActivate the subscription server side. This method is idempotent.- Throws:
JMSException
-
passivateMessageInput
void passivateMessageInput() throws JMSExceptionPassivate the subscription server side. This method is idempotent.- Throws:
JMSException
-
-