Configuring Java Message Service (JMS)-based client synchronization
You can use JMS-based client synchronization to keep data from the client near cache synchronized with other severs and clients.
Near cache
You can use the built-in Java™ Message Service (JMS)-based com.ibm.websphere.objectgrid.plugins.builtins.JMSObjectGridEventListener class to enable the client invalidation mechanism within a distributed eXtreme Scale environment.
The client invalidation mechanism is the solution for the issue of stale data in client near cache in distributed eXtreme Scale environment. This mechanism ensures that the client near cache is synchronized with servers or other clients. However, even with this JMS-based client invalidation mechanism, the client near cache does not immediately update. A delay occurs when the run time publishes updates.
- Client-server model: In this model, all server processes are in a publisher role that publishes all the transaction changes to the designated JMS destination. All client processes are in receiver roles and receive all transactional changes from the designated JMS destination.
- Client as dual roles model: In this model, all server processes have nothing to do with the JMS destination. All client processes are both JMS publisher and receiver roles. Transactional changes that occur on the client are published to the JMS destination and all the clients receive these transactional changes.
If you do not want to use JMS to synchronize your near cache, you can also use near cache invalidation. For more information, see Configuring near-cache invalidation.
Client-server model
client-server model XML example
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<objectGridConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ibm.com/ws/objectgrid/config ../objectGrid.xsd"
xmlns="http://ibm.com/ws/objectgrid/config">
<objectGrids>
<objectGrid name="AgentObjectGrid">
<bean id="ObjectGridEventListener"
className="com.ibm.websphere.objectgrid.plugins.builtins.JMSObjectGridEventListener">
<property name="invalidationModel" type="java.lang.String" value="CLIENT_SERVER_MODEL" description="" />
<property name="invalidationStrategy" type="java.lang.String" value="PUSH" description="" />
<property name="mapsToPublish" type="java.lang.String" value="agent;profile;pessimisticMap" description="" />
<property name="jms_topicConnectionFactoryJndiName" type="java.lang.String" value="defaultTCF" description="" />
<property name="jms_topicJndiName" type="java.lang.String" value="defaultTopic" description="" />
<property name="jms_topicName" type="java.lang.String" value="defaultTopic" description="" />
<property name="jms_userid" type="java.lang.String" value="" description="" />
<property name="jms_password" type="java.lang.String" value="" description="" />
<property name="jndi_properties" type="java.lang.String"
value="java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory;
java.naming.provider.url=
tcp://localhost:61616;connectionFactoryNames=defaultTCF;topic.defaultTopic=defaultTopic"
description="jndi properties" />
</bean>
<backingMap name="agent" readOnly="false" pluginCollectionRef="agent" preloadMode="false"
lockStrategy="OPTIMISTIC" copyMode="COPY_ON_READ_AND_COMMIT" ttlEvictorType="LAST_ACCESS_TIME"
timeToLive="28800" />
<backingMap name="profile" readOnly="false" pluginCollectionRef="profile" preloadMode="false"
lockStrategy="OPTIMISTIC" copyMode="COPY_ON_READ_AND_COMMIT" ttlEvictorType="LAST_ACCESS_TIME"
timeToLive="2700" />
<backingMap name="pessimisticMap" readOnly="false" pluginCollectionRef="pessimisticMap" preloadMode="false"
lockStrategy="PESSIMISTIC" copyMode="COPY_ON_READ_AND_COMMIT" ttlEvictorType="LAST_ACCESS_TIME"
timeToLive="2700" />
<backingMap name="excludedMap1" readOnly="false" pluginCollectionRef="excludedMap1" preloadMode="false"
lockStrategy="OPTIMISTIC" copyMode="COPY_ON_READ_AND_COMMIT" ttlEvictorType="LAST_ACCESS_TIME"
timeToLive="2700" />
<backingMap name="excludedMap2" readOnly="false" pluginCollectionRef="excludedMap2" preloadMode="false"
lockStrategy="OPTIMISTIC" copyMode="COPY_ON_READ_AND_COMMIT" ttlEvictorType="LAST_ACCESS_TIME"
timeToLive="2700" />
</objectGrid>
</objectGrids>
<backingMapPluginCollections>
<backingMapPluginCollection id="agent">
<bean id="ObjectTransformer" className="com.ibm.ws.objectgrid.test.scenario.AgentObjectTransformer" />
</backingMapPluginCollection>
<backingMapPluginCollection id="profile">
<bean id="ObjectTransformer" className="com.ibm.ws.objectgrid.test.scenario.ProfileObjectTransformer" />
<bean id="Evictor" className="com.ibm.websphere.objectgrid.plugins.builtins.LRUEvictor">
<property name="maxSize" type="int" value="2000" description="set max size for LRU evictor" />
<property name="sleepTime" type="int" value="15" description="evictor thread sleep time" />
<property name="numberOfLRUQueues" type="int" value="50" description="set number of LRU queues" />
</bean>
</backingMapPluginCollection>
<backingMapPluginCollection id="pessimisticMap" />
<backingMapPluginCollection id="excludedMap1" />
<backingMapPluginCollection id="excludedMap2" />
</backingMapPluginCollections>
</objectGridConfig>
Client as dual roles model
In client as dual roles model, each client has both JMS publisher and receiver roles. The client publishes every committed transactional change to a designated JMS destination and receives all the committed transactional changes from other clients. The server has nothing to do with JMS in this model.dual-roles model XML example
<?xml version="1.0" encoding="UTF-8"?>
<objectGridConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ibm.com/ws/objectgrid/config ../objectGrid.xsd"
xmlns="http://ibm.com/ws/objectgrid/config">
<objectGrids>
<objectGrid name="AgentObjectGrid">
<bean id="ObjectGridEventListener"
className="com.ibm.websphere.objectgrid.plugins.builtins.JMSObjectGridEventListener">
<property name="invalidationModel" type="java.lang.String" value="CLIENT_AS_DUAL_ROLES_MODEL" description="" />
<property name="invalidationStrategy" type="java.lang.String" value="PUSH" description="" />
<property name="mapsToPublish" type="java.lang.String" value="agent;profile;pessimisticMap" description="" />
<property name="jms_topicConnectionFactoryJndiName" type="java.lang.String" value="defaultTCF" description="" />
<property name="jms_topicJndiName" type="java.lang.String" value="defaultTopic" description="" />
<property name="jms_topicName" type="java.lang.String" value="defaultTopic" description="" />
<property name="jms_userid" type="java.lang.String" value="" description="" />
<property name="jms_password" type="java.lang.String" value="" description="" />
<property name="jndi_properties" type="java.lang.String"
value="java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory;java.naming.provider.url=
tcp://localhost:61616;connectionFactoryNames=defaultTCF;topic.defaultTopic=defaultTopic"
description="jndi properties" />
</bean>
<backingMap name="agent" readOnly="false" pluginCollectionRef="agent" preloadMode="false"
lockStrategy="OPTIMISTIC" copyMode="COPY_ON_READ_AND_COMMIT" ttlEvictorType="LAST_ACCESS_TIME"
timeToLive="28800" />
<backingMap name="profile" readOnly="false" pluginCollectionRef="profile" preloadMode="false"
lockStrategy="OPTIMISTIC" copyMode="COPY_ON_READ_AND_COMMIT" ttlEvictorType="LAST_ACCESS_TIME"
timeToLive="2700" />
<backingMap name="pessimisticMap" readOnly="false" pluginCollectionRef="pessimisticMap" preloadMode="false"
lockStrategy="PESSIMISTIC" copyMode="COPY_ON_READ_AND_COMMIT" ttlEvictorType="LAST_ACCESS_TIME"
timeToLive="2700" />
<backingMap name="excludedMap1" readOnly="false" pluginCollectionRef="excludedMap1" preloadMode="false"
lockStrategy="OPTIMISTIC" copyMode="COPY_ON_READ_AND_COMMIT" ttlEvictorType="LAST_ACCESS_TIME"
timeToLive="2700" />
<backingMap name="excludedMap2" readOnly="false" pluginCollectionRef="excludedMap2" preloadMode="false"
lockStrategy="OPTIMISTIC" copyMode="COPY_ON_READ_AND_COMMIT" ttlEvictorType="LAST_ACCESS_TIME"
timeToLive="2700" />
</objectGrid>
</objectGrids>
<backingMapPluginCollections>
<backingMapPluginCollection id="agent">
<bean id="ObjectTransformer" className="com.ibm.ws.objectgrid.test.scenario.AgentObjectTransformer" />
</backingMapPluginCollection>
<backingMapPluginCollection id="profile">
<bean id="ObjectTransformer" className="com.ibm.ws.objectgrid.test.scenario.ProfileObjectTransformer" />
<bean id="Evictor" className="com.ibm.websphere.objectgrid.plugins.builtins.LRUEvictor">
<property name="maxSize" type="int" value="2000" description="set max size for LRU evictor" />
<property name="sleepTime" type="int" value="15" description="evictor thread sleep time" />
<property name="numberOfLRUQueues" type="int" value="50" description="set number of LRU queues" />
</bean>
</backingMapPluginCollection>
<backingMapPluginCollection id="pessimisticMap" />
<backingMapPluginCollection id="excludedMap1" />
<backingMapPluginCollection id="excludedMap2" />
</backingMapPluginCollections>
</objectGridConfig>