com.ls.lars.communication
Class JMSListener
java.lang.Object
|
+--com.ls.lars.communication.JMSListener
- All Implemented Interfaces:
- Runnable
- public class JMSListener
- extends Object
- implements Runnable
JMSListener is used to listen to the JMS Server Queue for messages. It is used by a LARS server, started by
AgentJMSListener. In addition to the listening functionality, this listener can also get ClientMessengerFactory
to create a JMS messenger for the agent who sends the incoming message, if there is not one for it. In order to use
JMSListener, a JMS provider for example JBoss, has to be started up first.
- Version:
- $Revision: 1.12 $
- Author:
- Last modified by $Author: CReich $
Method Summary |
int |
nextJMSListenerId()
returns the next unique (within this Java Virtual Machine) id to be used in a JMS listener name |
void |
run()
Create a connection to the given JMS Server, so that this Listener can listen to the Queue |
void |
start()
starts the listener thread and sets the thread name |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
jmsListenerThreadId
public static int jmsListenerThreadId
- thread id for socket listeners
listenerThread
protected Thread listenerThread
- reference to this thread (needed for proper thread termination)
logger
protected ILogger logger
- the logger used by this Listener class for logging purpose
JMSListener
public JMSListener(String agentName,
String newJMSServerURLAddress,
String initialContext,
String sendingQueueName,
String receivingQueueName,
String securityPrincipal,
String securityCredentials)
- Constructor for JMSListener
- Parameters:
agentName
- Agent name of the clientnewJMSServerURLAddress
- The url address of the JMS serverinitialContext
- The JNDI initial context factory, usually defined by JMS providersendingQueueName
- The queue for sending JMS message to JMS server from within LARSreceivingQueueName
- The queue for receiving JMS message to JMS server from within LARSsecurityPrincipal
- The security principal, can be an empty String, but must not be nullsecurityCredentials
- The security credential, can be an empty String, but must not be null
start
public void start()
throws ProgrammingException
- starts the listener thread and sets the thread name
- Throws:
ProgrammingException
- If this listener was already started before
run
public void run()
- Create a connection to the given JMS Server, so that this Listener can listen to the Queue
- Specified by:
run
in interface Runnable
nextJMSListenerId
public int nextJMSListenerId()
- returns the next unique (within this Java Virtual Machine) id to be used in a JMS listener name
- Returns:
- the next JMS number