xmlBlaster 2.1.0 API

org.xmlBlaster.jms
Class XBMessageConsumer

java.lang.Object
  extended by org.xmlBlaster.jms.XBMessageConsumer
All Implemented Interfaces:
javax.jms.MessageConsumer, I_Callback
Direct Known Subclasses:
XBQueueReceiver, XBTopicSubscriber

public class XBMessageConsumer
extends java.lang.Object
implements javax.jms.MessageConsumer, I_Callback

XBMessageConsumer

Author:
Michele Laghi

Field Summary
protected  javax.jms.Destination destination
           
protected  javax.jms.ExceptionListener exceptionListener
           
protected  Global global
           
private static java.util.logging.Logger log
           
private  java.lang.String ME
           
protected  javax.jms.Message msg
           
protected  javax.jms.MessageListener msgListener
           
protected  java.lang.String msgSelector
           
protected  boolean noLocal
           
protected  boolean open
           
protected  XBSession session
           
protected  SubscribeReturnQos subscribeReturnQos
           
 
Constructor Summary
XBMessageConsumer(XBSession session, javax.jms.Destination destination, java.lang.String msgSelector, boolean noLocal)
          For each consumer created, an own xmlBlaster subscription is done since the msgSelector (i.e.
 
Method Summary
protected  void checkIfOpen(java.lang.String methodName)
           
 void close()
          unsubscribe here
 javax.jms.MessageListener getMessageListener()
           
 java.lang.String getMessageSelector()
           
private  java.lang.String getOid(javax.jms.Destination destination)
           
 javax.jms.Message receive()
           
 javax.jms.Message receive(long delay)
           
 javax.jms.Message receiveNoWait()
          Currently the implementation is such that if no msgListener has been associated to this consumer, the onMessage blocks until receiveNoWait has been invoked (if there is a message pending).
 void setMessageListener(javax.jms.MessageListener msgListener)
           
private  SubscribeReturnQos subscribe(javax.jms.Destination destination, java.lang.String msgSelector, boolean noLocal)
           
 java.lang.String update(java.lang.String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos)
          This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode about a new message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private java.lang.String ME

global

protected Global global

log

private static java.util.logging.Logger log

msgSelector

protected java.lang.String msgSelector

msgListener

protected javax.jms.MessageListener msgListener

session

protected XBSession session

msg

protected javax.jms.Message msg

subscribeReturnQos

protected SubscribeReturnQos subscribeReturnQos

destination

protected javax.jms.Destination destination

noLocal

protected boolean noLocal

exceptionListener

protected javax.jms.ExceptionListener exceptionListener

open

protected boolean open
Constructor Detail

XBMessageConsumer

XBMessageConsumer(XBSession session,
                  javax.jms.Destination destination,
                  java.lang.String msgSelector,
                  boolean noLocal)
            throws javax.jms.JMSException
For each consumer created, an own xmlBlaster subscription is done since the msgSelector (i.e. in xmlBlaster the mime plugin) could be different from one consumer to another. This is done in the constructor of the MessageConsumer. The msgSelector can be null.

Throws:
javax.jms.JMSException
Method Detail

checkIfOpen

protected final void checkIfOpen(java.lang.String methodName)
                          throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getOid

private final java.lang.String getOid(javax.jms.Destination destination)
                               throws javax.jms.JMSException
Throws:
javax.jms.JMSException

subscribe

private final SubscribeReturnQos subscribe(javax.jms.Destination destination,
                                           java.lang.String msgSelector,
                                           boolean noLocal)
                                    throws javax.jms.JMSException
Throws:
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
unsubscribe here

Specified by:
close in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException

getMessageListener

public javax.jms.MessageListener getMessageListener()
                                             throws javax.jms.JMSException
Specified by:
getMessageListener in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException

getMessageSelector

public java.lang.String getMessageSelector()
                                    throws javax.jms.JMSException
Specified by:
getMessageSelector in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException

receive

public javax.jms.Message receive()
                          throws javax.jms.JMSException
Specified by:
receive in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException

receive

public javax.jms.Message receive(long delay)
                          throws javax.jms.JMSException
Specified by:
receive in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException

receiveNoWait

public javax.jms.Message receiveNoWait()
                                throws javax.jms.JMSException
Currently the implementation is such that if no msgListener has been associated to this consumer, the onMessage blocks until receiveNoWait has been invoked (if there is a message pending). This has the disadvantage of blocking subscriptions of other sessions (or subscriptions on other topics). Using the get() method of XmlBlasterAccess would always return the last message (which is not wanted here). TODO we would need something as 'noInitialUpdates' for the getQos.

Specified by:
receiveNoWait in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException

setMessageListener

public void setMessageListener(javax.jms.MessageListener msgListener)
                        throws javax.jms.JMSException
Specified by:
setMessageListener in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException

update

public java.lang.String update(java.lang.String cbSessionId,
                               UpdateKey updateKey,
                               byte[] content,
                               UpdateQos updateQos)
                        throws XmlBlasterException
Description copied from interface: I_Callback
This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode about a new message.

So you should implement in your client code the I_Callback interface - suppling the update() method where you can do with the message whatever you want.

The raw protocol driver specific update() method (e.g. CORBA-BlasterCallback.update()) is unpacked and for each arrived message this update is called.

Specified by:
update in interface I_Callback
Parameters:
cbSessionId - The session ID specified by the client which registered the callback. You can specify a cbSessionId during connection (with ConnectQos) and this is bounced back here so you can authenticate the message.
updateKey - The arrived key containing the topic name
content - The arrived message content. This is your payload.
Throws:
XmlBlasterException
See Also:
I_XmlBlasterAccess

xmlBlaster 2.1.0 API

Copyright © 1999-2011 The xmlBlaster.org contributers.