This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I've tried out the standard JMS APIs but get an exception when trying to register a message listener on WAS.
The trace says:
As I understand now from here, it is not possible to run an implementor of MessageListener in a J2EE container. The article suggests to use MDBs for this purpose, but I do not want to use any EJB components unless there is no other way out.
So, is there a non-MDB way of registering message listeners in Websphere Application Server?
I was in a simillar situation a couple of weeks back. In my case it was a choice of using MDBs or using a Message Listener Container. Going the Spring route is quite easy you just need to define a Message Listener Container and inject your listener. Something like this:
After considering the pros and cons of both, i ended up using MDBs. hehe
Joined: May 04, 2009
and in the case of ehcache??
Joined: Aug 20, 2007
Here is how I think we can simulate JMS topic listeners in WAS without using MDBs :
1. Using the com.ibm.websphere.asynchbeans package, we can create AlarmManager and AlarmListener instances. These AlarmListeners are basically configured to be fired in certain intervals of time. Though, using these classes ties us to the WAS runtime, this is the most appropriate way of spawing threads from inside the thread-managed WAS environment.
2. Synchronous JMS receive calls like Subscriber.receive() can be used from inside the "fired" method of these AlarmListeners inorder to listen for messages on desired topics.
In other words - we spawn a thread which which keeps listening on topics using synchronous receive APIs.
It's highly probable that Spring too takes a similar approach.
I am not sure about ehcache - but the same can be done there too.
Joined: Aug 20, 2007
victor regpala wrote:I was in a simillar situation a couple of weeks back. In my case it was a choice of using MDBs or using a Message Listener Container. Going the Spring route is quite easy you just need to define a Message Listener Container and inject your listener. Something like this:
i would like to join in on this question too, i have same problem with oscache 2.3.2 (WebSphere 6.1).
[14.09.2009 14:39:17:414 EEST] 0000003d JMSBroadcasti I com.opensymphony.oscache.plugins.clustersupport.JMSBroadcastingListener initialize Starting JMS clustering (node name=node4, topic=OSCacheTopic, topic factory=OSCacheTopicFactory)
[14.09.2009 14:39:17:426 EEST] 0000003d AbstractCache E com.opensymphony.oscache.base.AbstractCacheAdministrator configureStandardListeners Could not initialize listener 'com.opensymphony.oscache.plugins.clustersupport.JMSBroadcastingListener'. Listener ignored.
com.opensymphony.oscache.base.InitializationException: Initialization of the JMSBroadcastingListener failed: javax.jms.IllegalStateException: CWSIA0084E: The method MessageConsumer.setMessageListener is not permitted in this container.
is this problem related with topic configurations? How can i resolve this without changing oscache code?