PRODUCTS AND SERVICES INDUSTRIES SUPPORT PARTNERS COMMUNITIES ABOUT
  Coherence Data Grid for Spring
  Data Grid Members
Added by Brian Oliver, last edited by Rob Misek on Jan 08, 2007  (view change)

Labels

 
(None)

Definition

Data Grid Members are Spring application processes that are either part of (running within), connected to or have access to a Data Grid - a Data Grid being a cluster of co-operating applications, clustered using Coherence to resiliently and scalably manage application state on Grid infrastructure.

In order for Spring applications to use Data Grid Beans and other Spring + Coherence Data Grid specific integration features, applications must be configured to be a <datagrid:member />.

Usage

To configure a Spring application to be a Data Grid Member, perform the following;

  • Add the xmlns:datagrid="http://schemas.tangosol.com/schema/datagrid-for-spring" declaration to the beans element.

Example:

application.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:datagrid="http://schemas.tangosol.com/schema/datagrid-for-spring"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
                           http://schemas.tangosol.com/schema/datagrid-for-spring http://schemas.tangosol.com/schema/datagrid-for-spring/datagrid-for-spring.xsd">	

    <datagrid:member />
	 	
</beans>

Data Grid Member Lifecycle Events

Once a Spring application is configured to be a Data Grid Member, it will process receive Data Grid Membership Events indicating when other Data Grid Members are (re)started and closed.

The com.tangosol.coherence.spring.datagrid.events package contains two events that capture Data Grid Membership lifecycles.

The DataGridApplicationContextClosedEvent is semantically equivalent to the org.springframework.context.event.ContextClosedEvent class but the instances are distributed to all existing Data Grid Members when a Data Grid Member leaves a Data Grid.

The DataGridApplicationContextRefreshedEvent is semantically equivalanet to the org.springframework.context.event.ContextRefreshedEvent class but instances are distributed to all existing Data Grid Members when a new Data Grid Member joins a Data Grid.

To receive and process these events (ie: construct an Event Handler), simply implement a org.springframework.context.ApplicationListener as you would do normally handle a org.springframework.context.ApplicationEvent. See the Spring Documentation for more details on creating Event Handlers.

Custom Data Grid Member Application Events

In addition to supporting Data Grid Lifecycle events, Data Grid Members may additionally publish and handle Data Grid Application Events.

Data Grid Application Events are an extension of the standard Spring Application Events org.springframework.context.ApplicationEvent with the exception that they are published to all Data Grid Members.

To create a Data Grid Application Event class, simply extend the org.springframework.context.ApplicationEvent class and implement the empty marker interface com.tangosol.coherence.spring.datagrid.events.DataGridApplicationEvent.

To publish a Data Grid Application Event, use the standard Spring applicationContext.publishEvent(...) method.