Click on Javadoc link to open Javadoc documentation.
Package
org.gridgain.grid.spi.communication.jms ![]()
Description
GridJmsCommunicationSpi ![]()
![]()
![]()
JMS topic will be used in which case a message will be sent to all nodes, but only destination node will process it and others will ignore it. JMS Topic is a mandatory parameter and is always used for communication with more than one node (method GridJmsCommunicationSpi.sendMessage(Collection, Serializable) ![]()
Configuration
Starting with release 1.6.0 GridGain comes with sample JMS configuration files for various providers, such as ActiveMQ, JBoss, SunMQ, etc... Please refer to examples/config folder under GridGain installation folder for more information.
The following configuration parameters can be used to configure GridJmsCommuncationSpi
| Setter Method | Description | Optional | Default |
|---|---|---|---|
| setConnectionFactoryName(String) |
JNDI name of JMS connection factory. | Yes. Either connection factory or connection factory name must be set. | — |
| setConnectionFactory(ConnectionFactory) |
JMS connection factory. (Since 1.6.0) | Yes. Either connection factory or connection factory name must be set. | — |
| setJndiEnvironment(Map) |
JNDI environment properties. For example, JBoss would require the following JNDI environment properties
|
Yes | — |
| setTopicName(String) |
JNDI name of JMS topic. | Yes. Either topic or topic name must be set. | — |
| setTopic(Topic) |
JMS topic. (Since 1.6.0) | Yes. Either topic or topic name must be set. | — |
| setQueueName(String) |
JNDI name of JMS queue. | Yes | null |
| setQueue(Queue) |
JMS queue. (Since 1.6.0) | Yes | null |
| setDeliveryMode(int) |
JMS message delivery mode. | Yes | javax.jms.Message.DEFAULT_DELIVERY_MODE |
| setPriority(int) |
JMS message priority. | Yes | javax.jms.Message.DEFAULT_PRIORITY |
| setTimeToLive(long) |
JMS message time to live. | Yes | javax.jms.Message.DEFAULT_TIME_TO_LIVE |
| setTransacted(boolean) |
Indicates whether JMS messages are transacted or not. | Yes | false |
| setUser(String) |
JMS connection user name for connectivity authentication. Note that if user is provided, then password must also be provided. | Yes | null which means that no authentication will be used. |
| setPassword(String) |
JMS connection password for connectivity authentication. Note that if password is provided, then user is also provided. | Yes | null which means that no authentication will be used. |
Examples
In order to use GridJmsCommunicationSpi ![]()
GridJmsCommunicationSpi commSpi = new GridJmsCommunicationSpi(); // JNDI connection factory name. commSpi.setConnectionFactoryName("java:ConnectionFactory"); // JNDI environment mandatory parameter. Map<Object, Object> env = new Hashtable<Object, Object>(3); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.PROVIDER_URL, "jnp://localhost:1099"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); commSpi.setJndiEnvironment(env); // JNDI topic name. commSpi.setTopicName("topic/myjmstopic"); GridConfigurationAdapter cfg = new GridConfigurationAdapter(); // Override default communication SPI. cfg.setCommunicationSpi(commSpi); // Start grid. GridFactory.start(cfg);
or from Spring configuration file
<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true"> ... <property name="communicationSpi"> <bean class="org.gridgain.grid.spi.communication.jms.GridJmsCommunicationSpi"> <property name="connectionFactoryName" value="java:ConnectionFactory"/> <property name="topicName" value="topic/myjmstopic"/> <property name="jndiEnvironment"> <map> <entry> <key><util:constant static-field="javax.naming.Context.INITIAL_CONTEXT_FACTORY"/></key> <value>org.jnp.interfaces.NamingContextFactory</value> </entry> <entry> <key><util:constant static-field="javax.naming.Context.PROVIDER_URL"/></key> <value>jnp://localhost:1099</value> </entry> <entry> <key><util:constant static-field="javax.naming.Context.URL_PKG_PREFIXES"/></key> <value>org.jboss.naming:org.jnp.interfaces</value> </entry> </map> </property> </bean> </property> ... </bean>

For more information about using Spring framework for configuration click here.
