Dashboard > GridGain User Guide > Table Of Contents > Developers Guide > Communication SPI
Communication SPI
Added by architect, last edited by morpheus on Dec 23, 2008  (view change)
Labels: 
(None)


Click on Javadoc link to open Javadoc documentation.

Package

org.gridgain.grid.spi.communication Javadoc

Built-in Implementations

Gridgain comes with following communication SPI's supported out of the box.

Description

GridCommunicationSpi Javadoc enables communication between different nodes within grid. It provides basic plumbing to send and receive grid messages and is utilized for all distributed grid operations, such as task execution, monitoring data exchange, distributed even querying and others.

To send and receive messages from public API, the following public methods are available

  • Grid.sendMessage(GridNode, Serializable) Javadoc
  • Grid.sendMessage(Collection<GridNode>, Serializable) Javadoc
  • Grid.addMessageListener(GridMessageListener) Javadoc
  • Grid.removeMessageListener(GridMessageListener) Javadoc

Note that messages can only be received asynchronously by registering GridMessageListener Javadoc with Grid Javadoc interface.

Usage

Here is an example of how to send and receive messages using public Grid Javadoc API

Grid grid = GridFactory.getGrid();

grid.addMessageListener(new GridMessageListener() {
        /**
         * @see GridMessageListener#onMessage(UUID,Serializable)
         */
        public void onMessage(UUID nodeId, Serializable msg) {
            System.out.println("Received message: " + msg);
        }
));

// Send message to itself.
grid.sendMessage(grid.getLocalNode(), "TEST");

GridConfiguration

GridCommunicationSpi is provided in Grid Configuration passed into GridFactory Javadoc at startup. By default GridTcpCommunicationSpi is used. You can configure a different communication SPI implementation as follows

GridConfigurationAdapter cfg = new GridConfigurationAdapter();

// Configure grid to use JGroups communication layer.
cfg.setCommunicationSpi(new GridJgroupsCommunicationSpi());

GridFactory.start(cfg);

Note that GridConfiguration interface is just a bean and can also be configured using spring XML configuration.

Default Implementation

If no communication SPI is provided in configuration by default GridTcpCommunicationSpi is used.

GridCoherenceCommunicationSpi (GridGain User Guide)
GridJgroupsCommunicationSpi (GridGain User Guide)
GridJmsCommunicationSpi (GridGain User Guide)
GridMailCommuncationSpi (GridGain User Guide)
GridMuleCommunicationSpi (GridGain User Guide)
GridTcpCommunicationSpi (GridGain User Guide)

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