|
|||||||||
| Home >> All >> org >> jgroups >> [ protocols overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.jgroups.protocols
Class JMS

java.lang.Objectorg.jgroups.stack.Protocol
org.jgroups.protocols.JMS
- All Implemented Interfaces:
- javax.jms.MessageListener
- public class JMS
- extends org.jgroups.stack.Protocol
- implements javax.jms.MessageListener
- extends org.jgroups.stack.Protocol
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 thejavax.naming.Context.INITIAL_CONTEXT_FACTORYproperty; you can specify it as the JVM system property-Djava.naming.factory.initial=factory.class.Name;providerURL- (optional), value of thejavax.naming.Context.PROVIDER_URLproperty; you can specify it as the JVM system property-Djava.naming.provider.url=some_urlttl- (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 org.jgroups.Address representing the JMS node ID or JMS topic group. |
| 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(org.jgroups.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(org.jgroups.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(org.jgroups.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 |
DEFAULT_CONNECTION_FACTORY
public static final java.lang.String DEFAULT_CONNECTION_FACTORY
- See Also:
- Constant Field Values
INIT_CONNECTION_FACTORY
public static final java.lang.String INIT_CONNECTION_FACTORY
- See Also:
- Constant Field Values
INIT_TOPIC_NAME
public static final java.lang.String INIT_TOPIC_NAME
- See Also:
- Constant Field Values
INIT_JNDI_CONTEXT
public static final java.lang.String INIT_JNDI_CONTEXT
- See Also:
- Constant Field Values
INIT_PROVIDER_URL
public static final java.lang.String INIT_PROVIDER_URL
- See Also:
- Constant Field Values
TIME_TO_LIVE
public static final java.lang.String TIME_TO_LIVE
- See Also:
- Constant Field Values
GROUP_NAME_PROPERTY
public static final java.lang.String GROUP_NAME_PROPERTY
- See Also:
- Constant Field Values
SRC_PROPERTY
public static final java.lang.String SRC_PROPERTY
- See Also:
- Constant Field Values
DEST_PROPERTY
public static final java.lang.String DEST_PROPERTY
- See Also:
- Constant Field Values
members
private final java.util.Vector members
connectionFactory
private javax.jms.TopicConnectionFactory connectionFactory
topic
private javax.jms.Topic topic
connection
private javax.jms.TopicConnection connection
session
private javax.jms.TopicSession session
publisher
private javax.jms.TopicPublisher publisher
subscriber
private javax.jms.TopicSubscriber subscriber
cfName
private java.lang.String cfName
topicName
private java.lang.String topicName
initCtxFactory
private java.lang.String initCtxFactory
providerUrl
private java.lang.String providerUrl
timeToLive
private long timeToLive
ctx
private javax.naming.Context ctx
group_addr
private java.lang.String group_addr
local_addr
private org.jgroups.Address local_addr
mcast_addr
private org.jgroups.Address mcast_addr
out_stream
private final java.io.ByteArrayOutputStream out_stream
RND
private static final java.util.Random RND
| Constructor Detail |
JMS
public JMS()
- Empty constructor.
| Method Detail |
getName
public java.lang.String getName()
- Get the name of the protocol.
toString
public java.lang.String toString()
- Get the string representation of the protocol.
setProperties
public boolean setProperties(java.util.Properties props)
- 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 thejavax.naming.Context.INITIAL_CONTEXT_FACTORYproperty; you can specify it as the JVM system property-Djava.naming.factory.initial=factory.class.Name;providerURL- (optional), value of thejavax.naming.Context.PROVIDER_URLproperty; you can specify it as the JVM system property-Djava.naming.provider.url=some_url
onMessage
public void onMessage(javax.jms.Message jmsMessage)
- Implementation of the
javax.jms.MessageListenerinterface. 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.- Specified by:
onMessagein interfacejavax.jms.MessageListener
handleDownEvent
protected void handleDownEvent(org.jgroups.Event evt)
- Handle down event, if it is not a Event.MSG type.
down
public void down(org.jgroups.Event evt)
- 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
handleDownEvent(Event)55 take care of it.
sendMessage
protected void sendMessage(org.jgroups.Message msg)
- Publish message in the JMS topic. We set the message source and
destination addresses if they were
null.
start
public void start()
throws java.lang.Exception
- 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.
stop
public void stop()
- Stops the work of the JMS protocol. This method closes JMS session and
connection and deregisters itself from the message notification.
generateLocalAddress
protected java.lang.String generateLocalAddress() throws java.net.UnknownHostException
- Generate random local address. This method takes host name and appends
it with randomly generated integer.
|
|||||||||
| Home >> All >> org >> jgroups >> [ protocols overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC