Can anyone advise whether this is possible and if so how the ehcache.xml should be configured and the custom connection factory be coded? I have it working for ActiveMQ which is well documented but can find no mention of WMQ.
Thanks in advance
WebSphereMQ is also JMS compliant as ActiveMQ, so your configuration might look like this (this configuration uses providerURL pointing to localhost, customize it to your needs):
<cache name="sampleCacheNorep"
maxEntriesLocalHeap="1000"
eternal="false"
timeToIdleSeconds="1000"
timeToLiveSeconds="1000"
overflowToDisk="false">
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.jms.JMSCacheReplicatorFactory"
properties="replicateAsynchronously=false, replicatePuts=false,
replicateUpdates=false, replicateUpdatesViaCopy=false,
replicateRemovals=false, loaderArgument=sampleCacheNorep"
propertySeparator=","/>
<cacheLoaderFactory
class="net.sf.ehcache.distribution.jms.JMSCacheLoaderFactory"
properties="initialContextFactoryName=netcom.ibm.mq.jms.context.WMQInitialContextFactory,
providerURL=localhost:1414/SYSTEM.DEF.SVRCONN,
replicationTopicConnectionFactoryBindingName=topicConnectionFactory,
getQueueConnectionFactoryBindingName=queueConnectionFactory,
replicationTopicBindingName=ehcache,
getQueueBindingName=ehcacheGetQueue,
timeoutMillis=10000"/>
</cache>
Related
I have the following configs in my IBM Liberty server.xml:
<!-- resource adapter location -->
<variable name="wmqJmsClient.rar.location" value="${shared.resource.dir}/lib/global/wmq.jmsra-9.1.0.0.rar"/>
<!-- jmsActivationSpec configs -->
<jmsActivationSpec authDataRef="myAuthData" id="my-app-name/MyMessageDrivenBean">
<properties.wmqJms destinationRef="jms/MyQueue"
destinationType="javax.jms.Queue"
sslCipherSuite="SSL_RSA_WITH_AES_256_CBC_SHA256"
channel="MY.MQCHANNEL"
queueManager="MY_QM"
hostName="myhost" port="32100"
transportType="CLIENT" />
</jmsActivationSpec>
I also have a message-driven bean I am using to handle messages that appear on the queue. And everything works fine.
I'd like to migrate to open-liberty and keep my JMS stuff but their documentation is a little bit different even though the same config elements are there.
Some properties are missing and it's not clear how to replace them. No hostName and port, instead I found only remoteServerAddress and it has to be a triplet host:port:something_i_dont_understand so not sure it's exactly the same :)
How can I configure all this required stuff in open-liberty to make my message-driven bean work?
Any help is appreciated :)
In WebSphere Liberty you are likely using the wmqJmsClient-2.0 feature. This isn't available in Open Liberty, but it is really only a convenience feature. You should be able to configure the following:
<featureManager>
<feature>jms-2.0</feature>
<feature>jca-1.7</feature>
</featureManager>
<resourceAdapter id="mqJMS" location="${shared.resource.dir}/lib/global/wmq.jmsra-9.1.0.0.rar"/>
<!-- jmsActivationSpec configs -->
<jmsActivationSpec authDataRef="myAuthData" id="my-app-name/MyMessageDrivenBean">
<properties.mqJms destinationRef="jms/MyQueue"
destinationType="javax.jms.Queue"
sslCipherSuite="SSL_RSA_WITH_AES_256_CBC_SHA256"
channel="MY.MQCHANNEL"
queueManager="MY_QM"
hostName="myhost" port="32100"
transportType="CLIENT" />
</jmsActivationSpec>
This configures the jms-2.0 feature, and the jca-1.7 which enables the JMS, and RA support in Liberty. The resourceAdapter element configures Liberty to know about the RA's existence and where it is (similar to the variable you have in your existing configuration). The value of the id attribute is then used on the properties element under the jmsActivationSpec element, so in the wmqJmsClient-2.0 feature we define this to be wmqJms, in this case I've used mqJms because I think wmqJms is reserved. In any case this config should work both in Open Liberty and WebSphere Liberty.
My problem is I don't know how i set StompSubProtocolHandler at XML
I try and know normal websocket set
<websocket:handlers allowed-origins="*">
<websocket:mapping path="/raphaServerHandler.do" handler="raphaServerHandler"/>
</websocket:handlers>
But I need to know setting StompSubProtocolHandler at XML!
It is done automatically by the:
<websocket:message-broker application-destination-prefix="/app">
<websocket:stomp-endpoint path="/foo" />
<websocket:simple-broker prefix="/topic" />
</websocket:message-broker>
<xsd:documentation><![CDATA[
Configures broker-backed messaging over WebSocket using a higher-level messaging sub-protocol.
Registers a SimpleUrlHandlerMapping and maps paths to registered Controllers.
A StompSubProtocolHandler is registered to handle various versions of the STOMP protocol.
See EnableWebSocketMessageBroker javadoc for information on code-based alternatives to enabling broker-backed messaging.
]]></xsd:documentation>
http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html#websocket-stomp-enable
I am using liferay 6.1 version.
I have created custom entities for portlet using service builder. I want to cache that custom entities.
I have set following properties in my portal-ext.properties to enable cache.
ehcache.statistics.enabled=true
value.object.entity.cache.enabled=true
value.object.finder.cache.enabled=true
velocity.engine.resource.manager.cache.enabled=true
layout.template.cache.enabled=true
net.sf.ehcache.configurationResourceName=/custom_cache/hibernate-clustered.xml
log4j.logger.net.sf.ehcache=DEBUG
log4j.logger.net.sf.ehcache.config=DEBUG
log4j.logger.net.sf.ehcache.distribution=DEBUG
log4j.logger.net.sf.ehcache.code=DEBUG
I created ehcache.xml file to override the ehcache-failsafe.xml to configure my custom entities so that it can enable for caching.
my ehcache.xml file is in my classpath [classpath:liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/classes].
<diskStore path="java.io.tmpdir/ehcache"/>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
maxElementsOnDisk="10000000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
<cache
eternal="false"
maxElementsInMemory="10000"
name="com.pr.test.model.impl.StudentImpl"
overflowToDisk="false"
timeToIdleSeconds="600"
timeToLiveSeconds="300"
statistics="true"
copyOnRead="true"
copyOnWrite="true"
clearOnFlush="true"
transactionalMode="off"
/>
Also create hibernate-clustered.xml file under src path [/docroot/WEB-INF/src] which is same as my ehcache.xml file.
since I am using service builder, cache-enable="true" is enough to cache the entities?
I use Jconsole to monitor the cache hits, But what the problem is the percentage for cache Misses is more than cache hits. Below is my statistics for caching :
Any help will be appreciated.
Caching is enabled by default for services built using liferay service builder.
I believe none of the steps mentioned above are required as cache is default enabled.
Below properties are set to true in default portal.properties and applies to all entities, not just for custom entities.
value.object.entity.cache.enabled=true
value.object.finder.cache.enabled=true
You can open *PersistenceImpl.java class for your custom entities to observe the caching code. Debugging this class could give you details on why its not hitting cache.
For example, calling API with cache off argument won't hit cache.
After a little research on ehcache we found that 'net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache' is the best match for our requirement.
I have followed suggestions given in the forum post (https://sourceforge.net/forum/message.php?msg_id=7382649) and realized that I can only replace the decorator cache with the actual ehcache with the help of a helper method on the CacheManager programmatically.
The question I wanted to ask is that using ehcache.xml file I was able to describe all the Ehcaches i wanted to use in my system. I feel its intuitive to declare the ehcache decorators as well in the XML itself so that I can completely centralize all my configuration at one place itself. i.e. ehcache XML. Is there a way we can add configuration for a decorator in the ehcache.xml itself ?
I found a good example of using cusom cache decorators
Specifying global EhCache capacity
<cache name="singleSharedCache" maxElementsInMemory="2000"
eternal="false" overflowToDisk="false">
<cacheDecoratorFactory class="com.xyz.util.CustomEhcacheDecoratorFactory"
properties="name=org.hibernate.tutorial.domain.Person" />
<cacheDecoratorFactory class="com.xyz.util.CustomEhcacheDecoratorFactory"
properties="name=org.hibernate.tutorial.domain.Event" />
</cache>
You should find all the information on this in the cache decorators documentation.
And it is indeed possible to declare decorated caches from XML.
I have setup my ehcache replication using RMI.However, I don't see any replication happening neither do I get any error.
Can you please take a look and let me know where I'm going wrong?I have tried both automatic and manual mode of discovery but to no avail.
I have enabled TRACE logging for net.sf hierarchy but I don't see any activity*.Can you please let me know how to visualise the replication,via logs?What category to add etc.*
My test scenario
I access jsp on host1 and thereafter on host2.When I then go back to host1 I expect to see some logs of replication or the replicated value coming back which I don't see.
Any help is appreciated.I have been struggling with this for quite sometime now.
My config is as follows
on host 1
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=manual,
rmiUrls=//host2:40001/reportsCache"/>
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="hostname=host1, port=40001, socketTimeoutMillis=3000"/>
on host 2
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=manual,
rmiUrls=//host1:40001/reportsCache"/>
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="hostname=host2, port=40001, socketTimeoutMillis=3000"/>
My ehcache config is as follows
<cache name="reportsCache"
maxElementsInMemory="1000"
maxElementsOnDisk="100"
eternal="false"
overflowToDisk="true"
timeToIdleSeconds="15"
timeToLiveSeconds="15"
statistics="true">
<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicateAsynchronously=true,
replicatePuts=true,
replicatePutsViaCopy=true,
replicateUpdates=true,
replicateUpdatesViaCopy=true,
replicateRemovals=true" />
<bootstrapCacheLoaderFactory
class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"/>
The relevant logger used is called net.sf.ehcache.distribution.RMICachePeer, where you have to enable DEBUG level.
How to configure the logger really depends on your logging framework. For log4j you would use something like the following in your log4j.properties file:
log4j.logger.net.sf.ehcache.distribution.RMICachePeer=DEBUG
For log4j2 put the following in your log4j2.xml:
<loggers>
...
<logger name="net.sf.ehcache.distribution.RMICachePeer" level="debug" />
</logger>
There was no problem as such.I think my testing was a bit off the mark.
I had the same jsp being accessed from two nodes(by 2 diff browser sessions) and was relying on my logs to see for cues regarding replication.I just changed my approach to see the content/data on the jsp and i see that the other node fetches the same data after a hit on the first node has been updated.So this is enough for my test.
however,I'm still curious to know how to see any logs about replication events?
I turned on a instance of ehcache-debugger too but i didn't see any thing coming up.
If anyone here can tell me how to see the logs pertaining to replication events that would be great.For the record,I have set the log level at TRACE for the net.sf package.