• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JMS topic listener without using MDBs

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

How can I create JMS topic listeners in WAS without using Message Driven Beans ?

Thanks in advance.
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's no need to use MDBs. Just using the standard messaging APIs to listen to the topic.

Have you tried any of the standard APIs?

Setting up JMS in WebSphere

-Cameron McKenzie
 
Akash Mohapatra
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Appreciate the quick response Cameron.

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?

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i would like to join in on this question, we have an even more severe problem becouse this is not our code, but rather Ehcache jms replication system. (so we cannot change this)

is there anyway to get around this?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

<bean id="messageListener" class="jms.client.SampleMessageListener"></bean>

<bean id="listener" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory">
<ref bean="jmsConnectionFactory" />
</property>
<property name="destination">
<ref bean="destination" />
</property>
<property name="messageListener">
<ref bean="messageListener" />
</property>
</bean>

Spring should handle everything for you.

After considering the pros and cons of both, i ended up using MDBs. hehe
 
Elhanan Maayan
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and in the case of ehcache??
 
Akash Mohapatra
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Thanks


 
Akash Mohapatra
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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:

<bean id="messageListener" class="jms.client.SampleMessageListener"></bean>

<bean id="listener" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory">
<ref bean="jmsConnectionFactory" />
</property>
<property name="destination">
<ref bean="destination" />
</property>
<property name="messageListener">
<ref bean="messageListener" />
</property>
</bean>

Spring should handle everything for you.

After considering the pros and cons of both, i ended up using MDBs. hehe



Can you please elaborate on the above pros and cons ?

Thanks
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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.
at com.opensymphony.oscache.plugins.clustersupport.JMSBroadcastingListener.initialize(JMSBroadcastingListener.java:144)
at com.opensymphony.oscache.base.AbstractCacheAdministrator.configureStandardListeners(AbstractCacheAdministrator.java:328)
at com.opensymphony.oscache.general.GeneralCacheAdministrator.createCache(GeneralCacheAdministrator.java:305)
at com.opensymphony.oscache.general.GeneralCacheAdministrator.<init>(GeneralCacheAdministrator.java:99)

is this problem related with topic configurations? How can i resolve this without changing oscache code?

Thanks...
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
WebSphere supports to listen to queues and topics without mdbs.

Simply instanciate a TopicSubscriber (IBM class) or create a message listener.



Source:
http://www.devops-insight.com/2014/08/jms-in-websphere.html
 
He baked a muffin that stole my car! And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic