| java.lang.Object java.lang.Thread org.jgroups.stack.UpHandler org.jgroups.protocols.JMS
JMS | public class JMS extends Protocol implements javax.jms.MessageListener(Code) | | 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.
author: Roman Rokytskyy (rrokytskyy@acm.org) |
Inner Class :public static class JMSAddress implements Address | |
Constructor Summary | |
public | JMS() Empty constructor. |
Method Summary | |
public void | down(Event evt) Called by the protocol above this. | protected String | generateLocalAddress() Generate random local address. | public String | getName() Get the name of the protocol. | protected void | handleDownEvent(Event evt) Handle down event, if it is not a Event.MSG type. | public void | onMessage(javax.jms.Message jmsMessage) Implementation of the 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. | protected void | sendMessage(Message msg) Publish message in the JMS topic. | public boolean | setProperties(Properties props) Set protocol properties. | public void | start() Start the JMS protocol. | public void | stop() Stops the work of the JMS protocol. | public String | toString() Get the string representation of the protocol. |
DEFAULT_CONNECTION_FACTORY | final public static String DEFAULT_CONNECTION_FACTORY(Code) | | |
GROUP_NAME_PROPERTY | final public static String GROUP_NAME_PROPERTY(Code) | | |
INIT_CONNECTION_FACTORY | final public static String INIT_CONNECTION_FACTORY(Code) | | |
INIT_JNDI_CONTEXT | final public static String INIT_JNDI_CONTEXT(Code) | | |
INIT_PROVIDER_URL | final public static String INIT_PROVIDER_URL(Code) | | |
INIT_TOPIC_NAME | final public static String INIT_TOPIC_NAME(Code) | | |
JMS | public JMS()(Code) | | Empty constructor.
|
down | public void down(Event evt)(Code) | | Called by the protocol above this. We check the event type, and if it is
message, we publish it in the topic, otherwise we let the
JMS.handleDownEvent(Event) take care of it.
Parameters: evt - event to process. |
generateLocalAddress | protected String generateLocalAddress() throws java.net.UnknownHostException(Code) | | Generate random local address. This method takes host name and appends
it with randomly generated integer.
randomly generated local address. |
getName | public String getName()(Code) | | Get the name of the protocol.
always returns the "JMS" string. |
handleDownEvent | protected void handleDownEvent(Event evt)(Code) | | Handle down event, if it is not a Event.MSG type.
Parameters: evt - event to handle. |
onMessage | public void onMessage(javax.jms.Message jmsMessage)(Code) | | Implementation of the 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 . |
sendMessage | protected void sendMessage(Message msg)(Code) | | Publish message in the JMS topic. We set the message source and
destination addresses if they were null .
Parameters: msg - message to publish. |
setProperties | public boolean setProperties(Properties props)(Code) | | Set protocol properties. Properties 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
|
start | public void start() throws Exception(Code) | | Start the JMS protocol. This method instantiates the JNDI initial context
and looks up the topic connection factory and topic itself. If this step
is successful, it creates a connection to JMS server, opens a session
and obtains publisher and subscriber instances.
throws: javax.jms.JMSException - if something goes wrong with JMS. throws: javax.naming.NamingException - if something goes wrong with JNDI. throws: IllegalArgumentException - if the connection factory or topiccannot be found under specified names. |
stop | public void stop()(Code) | | Stops the work of the JMS protocol. This method closes JMS session and
connection and deregisters itself from the message notification.
|
toString | public String toString()(Code) | | Get the string representation of the protocol.
string representation of the protocol (not very useful though). |
Fields inherited from org.jgroups.stack.UpHandler | final protected Log log(Code)(Java Doc)
|
|
|