|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object eu.semaine.jms.IOBase eu.semaine.jms.receiver.Receiver
public class Receiver
This class handles the common part to all message receivers in the SEMAINE system. Two models of use are possible:
receive()
,
receive(long)
or receiveNoWait()
directly;SEMAINEMessageAvailableListener
;
whenever a new message arrives, the Receiver thread will call that listener's
SEMAINEMessageAvailableListener.messageAvailableFrom(Receiver)
method.
The listener code then calls the Receiver's getMessage()
method from the
thread that should actually do the processing of the message. Note that in the
asynchronous API, the Receiver will block until getMessage() was called.createSEMAINEMessage(Message)
to do a meaningful analysis of the JMS message in terms of a suitable subclass of
SEMAINEMessage
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class eu.semaine.jms.IOBase |
---|
IOBase.ConnectionStatus, IOBase.Event |
Field Summary | |
---|---|
protected MessageConsumer |
consumer
|
protected SEMAINEMessageAvailableListener |
listener
|
protected JMSLogger |
log
|
protected SEMAINEMessage |
message
|
Fields inherited from class eu.semaine.jms.IOBase |
---|
connection, exception, isConnectionStarted, jmsPassword, jmsUrl, jmsUser, session, topic, topicName |
Constructor Summary | |
---|---|
Receiver(java.lang.String topicName)
Create a receiver that will listen for all messages in the given Topic on the default JMS server. |
|
Receiver(java.lang.String topicName,
java.lang.String messageSelector)
Create a receiver that will listen only to the messages in the given Topic that will pass the given messageSelector, on the default JMS server. |
|
Receiver(java.lang.String jmsUrl,
java.lang.String jmsUser,
java.lang.String jmsPassword,
java.lang.String topicName)
Create a receiver that will listen for all messages in the given Topic on the given JMS server. |
|
Receiver(java.lang.String jmsUrl,
java.lang.String jmsUser,
java.lang.String jmsPassword,
java.lang.String topicName,
java.lang.String messageSelector)
Create a receiver that will listen only to the messages in the given Topic that will pass the given messageSelector, on the given JMS server. |
Method Summary | |
---|---|
protected SEMAINEMessage |
createSEMAINEMessage(Message message)
Create a SEMAINE message from the given JMS message. |
SEMAINEMessage |
getMessage()
|
SEMAINEMessageAvailableListener |
getMessageListener()
|
java.lang.String |
getMessageSelector()
Get the message selector pattern active in this receiver to filter messages. |
static void |
main(java.lang.String[] args)
|
boolean |
notPickedUp()
|
void |
onMessage(Message m)
|
SEMAINEMessage |
receive()
Receives the next message produced for this message consumer. |
SEMAINEMessage |
receive(long timeout)
Receives the next message that arrives within the specified timeout interval. |
SEMAINEMessage |
receiveNoWait()
Receives the next message if one is immediately available. |
void |
setMessageListener(SEMAINEMessageAvailableListener aListener)
|
Methods inherited from class eu.semaine.jms.IOBase |
---|
createConnection, getConnection, getConnection, getConnectionStatus, getJMSPassword, getJMSUrl, getJMSUser, getSession, getTopic, getTopicName, isEmbeddedBroker, startConnection, useEmbeddedBroker |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected MessageConsumer consumer
protected SEMAINEMessageAvailableListener listener
protected JMSLogger log
protected SEMAINEMessage message
Constructor Detail |
---|
public Receiver(java.lang.String topicName) throws JMSException
jms.url
, default value tcp://localhost:61616
;jms.user
, default value null
;jms.password
, default value null
.
topic
- the name of the JMS Topic to listen to.
JMSException
public Receiver(java.lang.String topicName, java.lang.String messageSelector) throws JMSException
jms.url
, default value tcp://localhost:61616
;jms.user
, default value null
;jms.password
, default value null
.
topicName
- the name of the JMS Topic to listen to.messageSelector
- a message selector expression, see e.g. http://java.sun.com/javaee/5/docs/api/javax/jms/Message.html
for the detailed description.
JMSException
public Receiver(java.lang.String jmsUrl, java.lang.String jmsUser, java.lang.String jmsPassword, java.lang.String topicName) throws JMSException
jmsUrl
- the url where to contact the JMS serverjmsUser
- the username to use (can be null)jmsPassword
- the password to use (can be null)topic
- the name of the JMS Topic to listen to.
JMSException
public Receiver(java.lang.String jmsUrl, java.lang.String jmsUser, java.lang.String jmsPassword, java.lang.String topicName, java.lang.String messageSelector) throws JMSException
jmsUrl
- the url where to contact the JMS serverjmsUser
- the username to use (can be null)jmsPassword
- the password to use (can be null)topicName
- the name of the JMS Topic to listen to.messageSelector
- a message selector expression, see e.g. http://java.sun.com/javaee/5/docs/api/javax/jms/Message.html
for the detailed description.
JMSException
Method Detail |
---|
public java.lang.String getMessageSelector() throws JMSException
JMSException
protected SEMAINEMessage createSEMAINEMessage(Message message) throws MessageFormatException
message
- the JMS method to convert into a SEMAINE message.
MessageFormatException
- if the message format is problematic
java.lang.NullPointerException
- if message is null.public SEMAINEMessage receive() throws JMSException
JMSException
- if the JMS provider fails to receive the next message due to some internal error.public SEMAINEMessage receive(long timeout) throws JMSException
timeout
- the timeout value (in milliseconds)
JMSException
- if the JMS provider fails to receive the next message due to some internal error.public SEMAINEMessage receiveNoWait() throws JMSException
JMSException
- if the JMS provider fails to receive the next message due to some internal error.public void setMessageListener(SEMAINEMessageAvailableListener aListener) throws JMSException
JMSException
public SEMAINEMessageAvailableListener getMessageListener()
public void onMessage(Message m)
public SEMAINEMessage getMessage()
public boolean notPickedUp()
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |