|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jgroups.stack.Protocol
org.jgroups.protocols.JMS
public class JMS
Implementation of the transport protocol using the Java Message Service (JMS). This implementation depends on the JMS server that will distribute messages published to the specific topic to all topic subscribers.
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 java.lang.String |
DEFAULT_CONNECTION_FACTORY
|
static java.lang.String |
DEST_PROPERTY
|
static java.lang.String |
GROUP_NAME_PROPERTY
|
static java.lang.String |
INIT_CONNECTION_FACTORY
|
static java.lang.String |
INIT_JNDI_CONTEXT
|
static java.lang.String |
INIT_PROVIDER_URL
|
static java.lang.String |
INIT_TOPIC_NAME
|
static java.lang.String |
SRC_PROPERTY
|
static java.lang.String |
TIME_TO_LIVE
|
Fields inherited from class org.jgroups.stack.Protocol |
---|
down_handler, down_prot, down_queue, down_thread, down_thread_prio, log, observer, props, stack, stats, trace, up_handler, up_prot, up_queue, up_thread, up_thread_prio, warn |
Constructor Summary | |
---|---|
JMS()
Empty constructor. |
Method Summary | |
---|---|
void |
down(Event evt)
Called by the protocol above this. |
protected java.lang.String |
generateLocalAddress()
Generate random local address. |
java.lang.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(javax.jms.Message jmsMessage)
Implementation of the javax.jms.MessageListener interface. |
protected void |
sendMessage(Message msg)
Publish message in the JMS topic. |
boolean |
setProperties(java.util.Properties props)
Set protocol properties. |
void |
start()
Start the JMS protocol. |
void |
stop()
Stops the work of the JMS protocol. |
java.lang.String |
toString()
Get the string representation of the protocol. |
Methods inherited from class org.jgroups.stack.Protocol |
---|
destroy, downThreadEnabled, dumpStats, enableStats, getDownProtocol, getDownQueue, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, init, isTrace, isWarn, passDown, passUp, printStats, providedDownServices, providedUpServices, receiveDownEvent, receiveUpEvent, requiredDownServices, requiredUpServices, resetStats, setDownProtocol, setObserver, setPropertiesInternal, setProtocolStack, setTrace, setUpProtocol, setWarn, startDownHandler, startUpHandler, statsEnabled, stopInternal, up, upThreadEnabled |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_CONNECTION_FACTORY
public static final java.lang.String INIT_CONNECTION_FACTORY
public static final java.lang.String INIT_TOPIC_NAME
public static final java.lang.String INIT_JNDI_CONTEXT
public static final java.lang.String INIT_PROVIDER_URL
public static final java.lang.String TIME_TO_LIVE
public static final java.lang.String GROUP_NAME_PROPERTY
public static final java.lang.String SRC_PROPERTY
public static final java.lang.String DEST_PROPERTY
Constructor Detail |
---|
public JMS()
Method Detail |
---|
public java.lang.String getName()
getName
in class Protocol
"JMS"
string.public java.lang.String toString()
toString
in class java.lang.Object
public boolean setProperties(java.util.Properties props)
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
setProperties
in class Protocol
public void onMessage(javax.jms.Message jmsMessage)
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.
onMessage
in interface javax.jms.MessageListener
jmsMessage
- instance of javax.jms.Message
.protected void handleDownEvent(Event evt)
evt
- event to handle.public void down(Event evt)
handleDownEvent(Event)
take care of it.
down
in class Protocol
evt
- event to process.protected void sendMessage(Message msg)
null
.
msg
- message to publish.public void start() throws java.lang.Exception
start
in class Protocol
javax.jms.JMSException
- if something goes wrong with JMS.
javax.naming.NamingException
- if something goes wrong with JNDI.
java.lang.IllegalArgumentException
- if the connection factory or topic
cannot be found under specified names.
java.lang.Exception
- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack
to fail, so Channel.connect(String)
will throw an exceptionpublic void stop()
stop
in class Protocol
protected java.lang.String generateLocalAddress() throws java.net.UnknownHostException
java.net.UnknownHostException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |