I'm trying to setup the Ehcache replication using JMS WebsphereMQ v7 as a provider. I did this replication using ActiveMQ and everthing is ok, but I'm trying to figure out which class I need to use to create a initialContext.
This is the current code using ActiveMQ and working good, I good it from this post.
ehcache.xml
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="true"
monitoring="autodetect"
dynamicConfig="true">
<diskStore path="java.io.tmpdir" />
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.jms.JMSCacheManagerPeerProviderFactory"
properties="initialContextFactoryName=ca.toyota.testcache.cache.ActiveMQContextFactory,
providerURL=tcp://127.0.0.1:61616,
replicationTopicConnectionFactoryBindingName=topicConnectionFactory,
getQueueConnectionFactoryBindingName=queueConnectionFactory,
getQueueBindingName=ehcacheGetQueue,
listenToTopic=true,
replicationTopicBindingName=ehcache"
propertySeparator="," />
<cache name="cacheTest1"
maxEntriesLocalHeap="10000"
maxEntriesLocalDisk="1000"
eternal="false"
diskSpoolBufferSizeMB="20"
timeToIdleSeconds="300" timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
<persistence strategy="localTempSwap" />
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.jms.JMSCacheReplicatorFactory"
properties="replicateAsynchronously=true,
replicatePuts=true,
replicateUpdates=true,
replicateUpdatesViaCopy=true,
replicateRemovals=true,
asynchronousReplicationIntervalMillis=500"
propertySeparator="," />
</cache>
ActiveMQContextFactory.java:
package ca.toyota.testcache.cache;
import java.net.URISyntaxException;
import java.util.Hashtable;
import java.util.Map;
import javax.naming.Context;
import javax.naming.NamingException;
import org.apache.activemq.jndi.ActiveMQInitialContextFactory;
import net.sf.ehcache.distribution.jms.JMSUtil;
import net.sf.ehcache.util.concurrent.ConcurrentHashMap;
public class ActiveMQContextFactory extends ActiveMQInitialContextFactory {
@Override
public Context getInitialContext(Hashtable environment)
throws NamingException {
Map<String, Object> data = new ConcurrentHashMap<String, Object>();
// Configure the Topic connection factory binding name
String factoryBindingName = (String) environment
.get(JMSUtil.TOPIC_CONNECTION_FACTORY_BINDING_NAME);
try {
data.put(factoryBindingName, createConnectionFactory(environment));
} catch (URISyntaxException e) {
throw new NamingException("Error initialisating ConnectionFactory"
+ " with message " + e.getMessage());
}
String topicBindingName = (String) environment
.get(JMSUtil.REPLICATION_TOPIC_BINDING_NAME);
data.put(topicBindingName, createTopic(topicBindingName));
// Configure queue connection factory binding name
String getQueueConnectionfactoryBindingName = (String) environment
.get(JMSUtil.GET_QUEUE_CONNECTION_FACTORY_BINDING_NAME);
if (getQueueConnectionfactoryBindingName != null) {
try {
data.put(getQueueConnectionfactoryBindingName,
createConnectionFactory(environment));
} catch (URISyntaxException e) {
throw new NamingException(
"Error initialisating TopicConnectionFactory with message "
+ e.getMessage());
}
}
String getQueueBindingName = (String) environment
.get(JMSUtil.GET_QUEUE_BINDING_NAME);
if (getQueueBindingName != null) {
data.put(getQueueBindingName, createQueue(getQueueBindingName));
}
return createContext(environment, data);
}
}
Finally my question is: Which InitialContextFactory I should use to work with WebpshereMQ.
Thanks