org.jgroups.protocols
public class JMS extends Protocol implements MessageListener
Protocol parameters are:
topicName
- (required), full JNDI name of the topic to be
used for message publishing;
cf
- (optional), full JNDI name of the topic connection
factory that will create topic connection, default value is
"ConnectionFactory"
;
jndiCtx
- (optional), value of the
javax.naming.Context.INITIAL_CONTEXT_FACTORY
property; you can
specify it as the JVM system property
-Djava.naming.factory.initial=factory.class.Name
;
providerURL
- (optional), value of the
javax.naming.Context.PROVIDER_URL
property; you can specify it
as the JVM system property -Djava.naming.provider.url=some_url
ttl
- (required), time to live in milliseconds. Default
value is 0, that means that messages will never expire and will be
accumulated by a JMS server.
Note, when you are using the JMS protocol, try to avoid using protocols that open server socket connections, like FD_SOCK. I belive that FD is more appropriate failure detector for JMS case.
Nested Class Summary | |
---|---|
protected static class | JMS.JMSAddress
Simple Address representing the JMS node ID or JMS topic group. |
Field Summary | |
---|---|
static String | DEFAULT_CONNECTION_FACTORY |
static String | DEST_PROPERTY |
static String | GROUP_NAME_PROPERTY |
static String | INIT_CONNECTION_FACTORY |
static String | INIT_JNDI_CONTEXT |
static String | INIT_PROVIDER_URL |
static String | INIT_TOPIC_NAME |
static String | SRC_PROPERTY |
static String | TIME_TO_LIVE |
Constructor Summary | |
---|---|
JMS()
Empty constructor. |
Method Summary | |
---|---|
void | down(Event evt)
Called by the protocol above this. |
protected String | generateLocalAddress()
Generate random local address. |
String | getName()
Get the name of the protocol.
|
protected void | handleDownEvent(Event evt)
Handle down event, if it is not a Event.MSG type.
|
void | onMessage(Message jmsMessage)
Implementation of the javax.jms.MessageListener interface.
|
protected void | sendMessage(Message msg)
Publish message in the JMS topic. |
boolean | setProperties(Properties props)
Set protocol properties. |
void | start()
Start the JMS protocol. |
void | stop()
Stops the work of the JMS protocol. |
String | toString()
Get the string representation of the protocol.
|
Parameters: evt event to process.
Returns: randomly generated local address.
Returns: always returns the "JMS"
string.
Parameters: evt event to handle.
javax.jms.MessageListener
interface.
This method receives the JMS message, checks the destination group name.
If the group name is the same as the group name of this channel, it
checks the destination address. If destination address is either
multicast or is the same as local address then message is unwrapped and
passed up the protocol stack. Otherwise it is ignored.
Parameters: jmsMessage instance of javax.jms.Message
.
null
.
Parameters: msg message to publish.
topicName
- (required), full JNDI name of the topic to be
used for message publishing;
cf
- (optional), full JNDI name of the topic connection
factory that will create topic connection, default value is
"ConnectionFactory"
;
jndiCtx
- (optional), value of the
javax.naming.Context.INITIAL_CONTEXT_FACTORY
property; you can
specify it as the JVM system property
-Djava.naming.factory.initial=factory.class.Name
;
providerURL
- (optional), value of the
javax.naming.Context.PROVIDER_URL
property; you can specify it
as the JVM system property -Djava.naming.provider.url=some_url
Throws: javax.jms.JMSException if something goes wrong with JMS. javax.naming.NamingException if something goes wrong with JNDI. IllegalArgumentException if the connection factory or topic cannot be found under specified names.
Returns: string representation of the protocol (not very useful though).