|
||||||||||
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.sender.Sender
public class Sender
This class handles the common part to all message senders in the SEMAINE system.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class eu.semaine.jms.IOBase |
---|
IOBase.Event |
Field Summary | |
---|---|
protected java.lang.String |
datatype
The name of the data type being sent. |
protected int |
period
If data is periodic, the period in which data is sent, in milliseconds. |
protected javax.jms.MessageProducer |
producer
|
protected java.lang.String |
source
The name of the source component from where the data originated. |
Fields inherited from class eu.semaine.jms.IOBase |
---|
connection, isConnectionStarted, jmsPassword, jmsUrl, jmsUser, session, topic |
Constructor Summary | |
---|---|
Sender(java.lang.String topicName,
java.lang.String datatype,
java.lang.String source)
Create a new Sender to the given topic on the default JMS server. |
|
Sender(java.lang.String jmsUrl,
java.lang.String jmsUser,
java.lang.String jmsPassword,
java.lang.String topicName,
java.lang.String datatype,
java.lang.String source)
Create a new Sender to the given topic on the given JMS server. |
Method Summary | |
---|---|
protected void |
fillMessageProperties(javax.jms.Message message,
long usertime)
Fill in the usual message properties as far as possible. |
java.lang.String |
getDatatype()
The name of the data type sent. |
int |
getPeriod()
For periodic senders, get the period of sending. |
java.lang.String |
getSource()
The name of the source component sending the data. |
long |
getTimeToLive()
Get the time to live for all messages sent by this sender, i.e. the number of milliseconds before the message is considered obsolete by the JMS system. |
protected void |
initialise(java.lang.String datatype,
java.lang.String source)
|
boolean |
isEventBased()
Test whether this sender is set to send messages in an event-based way. |
boolean |
isPeriodic()
Test whether this sender is set to send messages periodically. |
static void |
main(java.lang.String[] args)
|
void |
sendTextMessage(java.lang.String text,
long usertime)
Send a text message via this sender. |
void |
sendTextMessage(java.lang.String text,
long usertime,
IOBase.Event eventType)
Send a text message via this sender, for event-based messages. |
void |
setEventBased()
Determine that the data is event-based, not periodic. |
void |
setPeriodic(int aPeriod)
Determine that the data is periodic, and set the period in which data is (intended to be) sent, in milliseconds. |
void |
setTimeToLive(long aTimeToLive)
Set the time to live for all messages sent by this sender, i.e. the number of milliseconds before the message is considered obsolete by the JMS system. |
Methods inherited from class eu.semaine.jms.IOBase |
---|
getConnection, getJMSUrl, getSession, getTopic, getTopicName, startConnection |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected javax.jms.MessageProducer producer
protected java.lang.String datatype
protected java.lang.String source
protected int period
Constructor Detail |
---|
public Sender(java.lang.String topicName, java.lang.String datatype, java.lang.String source) throws javax.jms.JMSException
jms.url
, default value tcp://localhost:61616
;jms.user
, default value null
;jms.password
, default value null
.
topic
- the name of the topic to send to.datatype
- the name of the type of data being sent.source
- the name of the component sending the data.
javax.jms.JMSException
java.lang.NullPointerException
- if any of the parameters topicName, datatype, or source are null.public Sender(java.lang.String jmsUrl, java.lang.String jmsUser, java.lang.String jmsPassword, java.lang.String topicName, java.lang.String datatype, java.lang.String source) throws javax.jms.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 topic to send to.datatype
- the name of the type of data being sent.source
- the name of the component sending the data.
javax.jms.JMSException
java.lang.NullPointerException
- if any of the parameters jmsUrl, topicName, datatype, or source are null.Method Detail |
---|
protected void initialise(java.lang.String datatype, java.lang.String source) throws javax.jms.JMSException
javax.jms.JMSException
public java.lang.String getDatatype()
public java.lang.String getSource()
public void setPeriodic(int aPeriod)
aPeriod
- the period in which data is to be sent.
java.lang.IllegalArgumentException
- if aPeriod is <= 0.public void setEventBased()
#sendTextMessage(String, long, eu.semaine.jms.IOBase.Event)}.
public boolean isPeriodic()
public boolean isEventBased()
public int getPeriod()
public void setTimeToLive(long aTimeToLive) throws javax.jms.JMSException
aTimeToLive
- time to live, in milliseconds.
A value of 0 means unlimited time, i.e. the messages will not expire.
javax.jms.JMSException
public long getTimeToLive() throws javax.jms.JMSException
javax.jms.JMSException
public void sendTextMessage(java.lang.String text, long usertime) throws javax.jms.JMSException
datatype
is a String property containing the value produced by getDatatype()
;source
is a String property containing the value produced by getSource()
;usertime
is a long property containing the value of parameter usertime
;isPeriodic()
returns true
),
period
is an int property containing the value returned by getPeriod()
;event
is a String property; as
this method does not specify an event type, the default value single
is assumed.getTimeToLive()
returns a non-zero value, the message will
contain a header field JMSExpiration
containing the time when the message
will expire.
text
- the message text.usertime
- the "user" time that this message refers to,
in milliseconds since 1970.
java.lang.IllegalStateException
- if the connection is not started or the sender is in event-based mode.
javax.jms.JMSException
public void sendTextMessage(java.lang.String text, long usertime, IOBase.Event eventType) throws javax.jms.JMSException
datatype
is a String property containing the value produced by getDatatype()
;source
is a String property containing the value produced by getSource()
;usertime
is a long property containing the value of parameter usertime
;event
is a String property containing
the String representation of the event parameter to this method.getTimeToLive()
returns a non-zero value, the message will
contain a header field JMSExpiration
containing the time when the message
will expire.
text
- the message text.usertime
- the "user" time that this message refers to,
in milliseconds since 1970.event
- the type of event represented by this message.
java.lang.IllegalStateException
- if the connection is not started or the sender is in periodic mode.
javax.jms.JMSException
protected void fillMessageProperties(javax.jms.Message message, long usertime) throws javax.jms.JMSException
super.fillMessageProperties(message, usertime)
).
a
- message object in preparation for sending.usertime
- the "user" time that this message refers to,
in milliseconds since 1970.
javax.jms.JMSException
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 |