xmlBlaster 2.2.0 API

org.xmlBlaster.jms
Class XBSession

java.lang.Object
  extended by java.lang.Thread
      extended by org.xmlBlaster.jms.XBSession
All Implemented Interfaces:
java.lang.Runnable, javax.jms.Session, I_Callback
Direct Known Subclasses:
XBQueueSession, XBTopicSession

public class XBSession
extends java.lang.Thread
implements javax.jms.Session, I_Callback

XBSession

Author:
Michele Laghi

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  int ackMode
           
protected  java.util.concurrent.LinkedBlockingQueue<XBMsgEvent> channel
           
(package private)  XBConnection connection
           
protected  boolean connectionActivated
           
protected  java.util.Map consumerMap
           
protected  java.lang.Thread controlThread
          Set in the constructor it can be changed in the update methods (also of the message consumers) only.
protected  boolean durableDefault
           
protected  java.util.HashMap durableSubscriptionMap
           
protected  javax.jms.ExceptionListener exceptionListener
           
protected  Global global
           
private static java.util.logging.Logger log
           
private static java.lang.String ME
           
(package private) static int MODE_ASYNC
           
(package private) static int MODE_SYNC
           
(package private) static int MODE_UNSET
           
protected  javax.jms.MessageListener msgListener
           
protected  java.lang.String msgSelectorDefault
           
protected  boolean noLocalDefault
           
protected  boolean open
           
protected  java.lang.String sessionName
           
private  boolean started
           
private  I_StatusChangeListener statusChangeListener
           
protected  int syncMode
           
private  boolean tmpBypassCheckSet
           
protected  boolean transacted
           
protected  long updateTimeout
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface javax.jms.Session
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED
 
Constructor Summary
XBSession(Global global, int ackMode, boolean transacted)
          This constructor is used if you want to pass a Global which has already done some work (connected) on the I_XmlBlasterAccess.
XBSession(XBConnection connection, int ackMode, boolean transacted)
          This constructor extracts the global from the ConnectQos.
 
Method Summary
(package private)  void activateDispatcher(boolean doActivate)
          Activates or deactivates the dispatcher associated to this session.
(package private)  void checkControlThread()
           
protected  void checkIfOpen(java.lang.String methodName)
           
protected  void checkIfTransacted(java.lang.String methodName)
           
 void close()
          It disconnects from xmlBlaster and deregisters from its XBConnection
 void commit()
           
(package private)  java.lang.String connect()
           
 javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue)
           
 javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue, java.lang.String msgSelector)
           
 javax.jms.BytesMessage createBytesMessage()
           
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination)
          For each consumer created, an own xmlBlaster subscription is done since the msgSelector (i.e.
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, java.lang.String msgSelector)
           
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, java.lang.String msgSelector, boolean noLocal)
           
 javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, java.lang.String name)
           
 javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, java.lang.String name, java.lang.String msgSelector, boolean noLocal)
           
 javax.jms.MapMessage createMapMessage()
           
 javax.jms.Message createMessage()
           
 javax.jms.ObjectMessage createObjectMessage()
           
 javax.jms.ObjectMessage createObjectMessage(java.io.Serializable content)
           
 javax.jms.MessageProducer createProducer(javax.jms.Destination destination)
           
 javax.jms.Queue createQueue(java.lang.String queueName)
           
 XBStreamingMessage createStreamingMessage(I_ReplaceContent replaceContent)
           
 javax.jms.StreamMessage createStreamMessage()
           
 javax.jms.TemporaryQueue createTemporaryQueue()
           
 javax.jms.TemporaryTopic createTemporaryTopic()
           
 javax.jms.TextMessage createTextMessage()
           
 javax.jms.TextMessage createTextMessage(java.lang.String text)
           
 javax.jms.Topic createTopic(java.lang.String name)
           
 int getAcknowledgeMode()
           
 javax.jms.MessageListener getMessageListener()
           
(package private)  int getSyncMode()
           
 boolean getTransacted()
           
(package private)  long getUpdateTimeout()
           
private  void postConstructor(int ackMode, boolean transacted)
           
 void recover()
           
 void rollback()
           
 void run()
           
(package private)  void setControlThread(java.lang.Thread controlThread)
           
 void setMessageListener(javax.jms.MessageListener msgListener)
           
(package private)  void setStatusChangeListener(I_StatusChangeListener statusChangeListener)
          registeres the listener about status changes.
(package private)  void setSyncMode(int asyncMode)
           
 void unsubscribe(java.lang.String subName)
           
 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.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MODE_UNSET

static final int MODE_UNSET
See Also:
Constant Field Values

MODE_ASYNC

static final int MODE_ASYNC
See Also:
Constant Field Values

MODE_SYNC

static final int MODE_SYNC
See Also:
Constant Field Values

ME

private static final java.lang.String ME
See Also:
Constant Field Values

global

protected Global global

log

private static java.util.logging.Logger log

connection

XBConnection connection

ackMode

protected int ackMode

noLocalDefault

protected final boolean noLocalDefault
See Also:
Constant Field Values

durableDefault

protected final boolean durableDefault
See Also:
Constant Field Values

msgSelectorDefault

protected final java.lang.String msgSelectorDefault

msgListener

protected javax.jms.MessageListener msgListener

durableSubscriptionMap

protected java.util.HashMap durableSubscriptionMap

open

protected boolean open

transacted

protected boolean transacted

syncMode

protected int syncMode

updateTimeout

protected long updateTimeout

consumerMap

protected java.util.Map consumerMap

tmpBypassCheckSet

private boolean tmpBypassCheckSet

controlThread

protected java.lang.Thread controlThread
Set in the constructor it can be changed in the update methods (also of the message consumers) only.


sessionName

protected java.lang.String sessionName

statusChangeListener

private I_StatusChangeListener statusChangeListener

exceptionListener

protected javax.jms.ExceptionListener exceptionListener

connectionActivated

protected boolean connectionActivated

channel

protected java.util.concurrent.LinkedBlockingQueue<XBMsgEvent> channel

started

private boolean started
Constructor Detail

XBSession

XBSession(XBConnection connection,
          int ackMode,
          boolean transacted)
This constructor extracts the global from the ConnectQos. Note that you need to clone the ConnectQos before passing it to this constructor. global contained in the connectQos.

Parameters:
connectQos - is the connectQos to be used for this session. It is an own instance and can not be null.

XBSession

public XBSession(Global global,
                 int ackMode,
                 boolean transacted)
This constructor is used if you want to pass a Global which has already done some work (connected) on the I_XmlBlasterAccess. Caution, you will not be able to connect and disconnect if you use this constructor.

Parameters:
global -
ackMode -
transacted -
Method Detail

postConstructor

private final void postConstructor(int ackMode,
                                   boolean transacted)

setStatusChangeListener

void setStatusChangeListener(I_StatusChangeListener statusChangeListener)
registeres the listener about status changes. In general this listener is the owner XBConnection since it needs to be notified everytime one of its sessions is closing. Care must be used when invoking since this is not synchronized.

Parameters:
statusChangeListener -

activateDispatcher

final void activateDispatcher(boolean doActivate)
                       throws XmlBlasterException
Activates or deactivates the dispatcher associated to this session. It does it only if the Session is in ASYNC Mode.

Parameters:
doActivate -
Throws:
XmlBlasterException

connect

java.lang.String connect()
                   throws javax.jms.JMSException
Returns:
a string containing the complete session name.
Throws:
javax.jms.JMSException

checkIfOpen

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

checkIfTransacted

protected final void checkIfTransacted(java.lang.String methodName)
                                throws javax.jms.IllegalStateException
Throws:
javax.jms.IllegalStateException

checkControlThread

final void checkControlThread()
                       throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createDurableSubscriber

public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic,
                                                         java.lang.String name)
                                                  throws javax.jms.JMSException
Specified by:
createDurableSubscriber in interface javax.jms.Session
Throws:
javax.jms.JMSException

createDurableSubscriber

public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic,
                                                         java.lang.String name,
                                                         java.lang.String msgSelector,
                                                         boolean noLocal)
                                                  throws javax.jms.JMSException
Specified by:
createDurableSubscriber in interface javax.jms.Session
Throws:
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
It disconnects from xmlBlaster and deregisters from its XBConnection

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

commit

public void commit()
            throws javax.jms.JMSException
Specified by:
commit in interface javax.jms.Session
Throws:
javax.jms.JMSException

createBytesMessage

public javax.jms.BytesMessage createBytesMessage()
                                          throws javax.jms.JMSException
Specified by:
createBytesMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createMapMessage

public javax.jms.MapMessage createMapMessage()
                                      throws javax.jms.JMSException
Specified by:
createMapMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createMessage

public javax.jms.Message createMessage()
                                throws javax.jms.JMSException
Specified by:
createMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createObjectMessage

public javax.jms.ObjectMessage createObjectMessage()
                                            throws javax.jms.JMSException
Specified by:
createObjectMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createObjectMessage

public javax.jms.ObjectMessage createObjectMessage(java.io.Serializable content)
                                            throws javax.jms.JMSException
Specified by:
createObjectMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createStreamMessage

public javax.jms.StreamMessage createStreamMessage()
                                            throws javax.jms.JMSException
Specified by:
createStreamMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createStreamingMessage

public XBStreamingMessage createStreamingMessage(I_ReplaceContent replaceContent)
                                          throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createTextMessage

public javax.jms.TextMessage createTextMessage()
                                        throws javax.jms.JMSException
Specified by:
createTextMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createTextMessage

public javax.jms.TextMessage createTextMessage(java.lang.String text)
                                        throws javax.jms.JMSException
Specified by:
createTextMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

getMessageListener

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

getTransacted

public boolean getTransacted()
                      throws javax.jms.JMSException
Specified by:
getTransacted in interface javax.jms.Session
Throws:
javax.jms.JMSException

recover

public void recover()
             throws javax.jms.JMSException
Specified by:
recover in interface javax.jms.Session
Throws:
javax.jms.JMSException

rollback

public void rollback()
              throws javax.jms.JMSException
Specified by:
rollback in interface javax.jms.Session
Throws:
javax.jms.JMSException

run

public void run()
Specified by:
run in interface java.lang.Runnable
Specified by:
run in interface javax.jms.Session
Overrides:
run in class java.lang.Thread

setMessageListener

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

createQueue

public javax.jms.Queue createQueue(java.lang.String queueName)
                            throws javax.jms.JMSException
Specified by:
createQueue in interface javax.jms.Session
Throws:
javax.jms.JMSException

createBrowser

public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue)
                                     throws javax.jms.JMSException
Specified by:
createBrowser in interface javax.jms.Session
Throws:
javax.jms.JMSException

createBrowser

public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue,
                                            java.lang.String msgSelector)
                                     throws javax.jms.JMSException
Specified by:
createBrowser in interface javax.jms.Session
Throws:
javax.jms.JMSException

createTemporaryQueue

public javax.jms.TemporaryQueue createTemporaryQueue()
                                              throws javax.jms.JMSException
Specified by:
createTemporaryQueue in interface javax.jms.Session
Throws:
javax.jms.JMSException

getAcknowledgeMode

public int getAcknowledgeMode()
                       throws javax.jms.JMSException
Specified by:
getAcknowledgeMode in interface javax.jms.Session
Throws:
javax.jms.JMSException

createProducer

public javax.jms.MessageProducer createProducer(javax.jms.Destination destination)
                                         throws javax.jms.JMSException
Specified by:
createProducer in interface javax.jms.Session
Throws:
javax.jms.JMSException

createConsumer

public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination)
                                         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 and

Specified by:
createConsumer in interface javax.jms.Session
Throws:
javax.jms.JMSException

createConsumer

public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination,
                                                java.lang.String msgSelector)
                                         throws javax.jms.JMSException
Specified by:
createConsumer in interface javax.jms.Session
Throws:
javax.jms.JMSException

createConsumer

public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination,
                                                java.lang.String msgSelector,
                                                boolean noLocal)
                                         throws javax.jms.JMSException
Specified by:
createConsumer in interface javax.jms.Session
Throws:
javax.jms.JMSException

createTopic

public javax.jms.Topic createTopic(java.lang.String name)
                            throws javax.jms.JMSException
Specified by:
createTopic in interface javax.jms.Session
Throws:
javax.jms.JMSException

unsubscribe

public void unsubscribe(java.lang.String subName)
                 throws javax.jms.JMSException
Specified by:
unsubscribe in interface javax.jms.Session
Throws:
javax.jms.JMSException

createTemporaryTopic

public javax.jms.TemporaryTopic createTemporaryTopic()
                                              throws javax.jms.JMSException
Specified by:
createTemporaryTopic in interface javax.jms.Session
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

getSyncMode

int getSyncMode()
Returns:
Returns the asyncMode.

setSyncMode

void setSyncMode(int asyncMode)
Parameters:
asyncMode - The asyncMode to set. This method starts the runner thread if not running yet in case async is set.

setControlThread

void setControlThread(java.lang.Thread controlThread)

getUpdateTimeout

long getUpdateTimeout()

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.