Dashboard > GridGain User Guide > Table Of Contents > Developers Guide > Discovery SPI > GridJmsDiscoverySpi
GridJmsDiscoverySpi
Added by user-1-ds, last edited by ghost on Aug 25, 2008  (view change)
Labels: 
(None)


Click on Javadoc link to open Javadoc documentation.

Package

org.gridgain.grid.spi.discovery.jms Javadoc

Description

JMS implementation of GridDiscoverySpi Javadoc SPI. This is a topic-based implementation. Topic will be first obtained from JNDI lookup.

Configuration

The following configuration parameters can be used to configure GridJmsDiscoverySpi

Setter Method Description Optional Default
setConnectionFactoryName(String) Javadoc JNDI name of JMS connection factory. Yes. Either connection factory or connection factory name must be set.
setConnectionFactory(ConnectionFactory) Javadoc JMS connection factory. (Since 1.6.0) Yes. Either connection factory or connection factory name must be set.
setJndiEnvironment(Map) Javadoc JNDI environment properties. For example, JBoss would require the following JNDI environment properties
  • javax.naming.Context.INITIAL_CONTEXT_FACTORY
  • javax.naming.Context.PROVIDER_URL
  • javax.naming.Context.URL_PKG_PREFIXES
Yes
setTopicName(String) Javadoc JNDI name of JMS topic. Yes. Either topic or topic name must be set.
setTopic(Topic) Javadoc JMS topic. (Since 1.6.0) Yes. Either topic or topic name must be set.
setHeartbeatFrequency(long) Javadoc Interval for sending heartbeat requests. Yes 10000 milliseconds specified by GridJmsDiscoveryConfiguration.DFLT_HEARTBEAT_FREQ Javadoc .
setMaximumMissedHeartbeats(long) Javadoc Number of heartbeat requests that could be missed until remote node becomes unavailable. Yes 3 (specified by GridJmsDiscoveryConfiguration.DFLT_MAX_MISSED_HEARTBEATS Javadoc )
setTimeToLive(long) Javadoc JMS message time to live. Yes javax.jms.Message.DEFAULT_TIME_TO_LIVE
setPingWaitTime(long) Javadoc Ping request timeout. Yes 5000 (specified by GridJmsDiscoveryConfiguration.DFLT_PING_WAIT_TIME Javadoc )
setHandshakeWaitTime(long) Javadoc Handshake timeout. Yes 5000 (specified by GridJmsDiscoveryConfiguration.DFLT_HANDSHAKE_WAIT_TIME Javadoc )
setUser(String) Javadoc 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) Javadoc 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) Javadoc 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 Javadoc )

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.

Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.10 Build:#528 Nov 29, 2006) - Bug/feature request - Contact Administrators