Click on Javadoc link to open Javadoc documentation.
Package
org.gridgain.grid.spi.discovery.jms ![]()
Description
JMS implementation of GridDiscoverySpi ![]()
Configuration
The following configuration parameters can be used to configure GridJmsDiscoverySpi
| 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. | — |
| setHeartbeatFrequency(long) |
Interval for sending heartbeat requests. | Yes | 10000 milliseconds specified by GridJmsDiscoveryConfiguration.DFLT_HEARTBEAT_FREQ |
| setMaximumMissedHeartbeats(long) |
Number of heartbeat requests that could be missed until remote node becomes unavailable. | Yes | 3 (specified by GridJmsDiscoveryConfiguration.DFLT_MAX_MISSED_HEARTBEATS |
| setTimeToLive(long) |
JMS message time to live. | Yes | javax.jms.Message.DEFAULT_TIME_TO_LIVE |
| setPingWaitTime(long) |
Ping request timeout. | Yes | 5000 (specified by GridJmsDiscoveryConfiguration.DFLT_PING_WAIT_TIME |
| setHandshakeWaitTime(long) |
Handshake timeout. | Yes | 5000 (specified by GridJmsDiscoveryConfiguration.DFLT_HANDSHAKE_WAIT_TIME |
| 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. |
| setMaximumHandshakeThreads(int) |
Maximum number of handshake threads. This means maximum number of handshakes that can be executed in parallel. (Since 2.1.0) | Yes | 10 (specified by GridJmsDiscoveryConfiguration.DFLT_MAX_HANDSHAKE_THREADS |
Examples
GridJmsDiscoverySpi needs to be explicitly configured to override default Multicast discovery SPI.
GridJmsDiscoverySpi spi = new GridJmsDiscoverySpi(); // JNDI connection factory name. spi.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"); spi.setJndiEnvironment(env); // JNDI topic name. spi.setTopicName("topic/myjmstopic"); GridConfigurationAdapter cfg = new GridConfigurationAdapter(); // Override default discovery SPI. cfg.setDiscoverySpi(spi); // Start grid. GridFactory.start(cfg);
or from Spring configuration file
<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true"> ... <property name="discoverySpi"> <bean class="org.gridgain.grid.spi.discovery.jms.GridJmsDiscoverySpi"> <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.
