Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

doubts with MDB as topic subscriber

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I implemented a Topic, where an application client is listening to a Topic, and the message is being published by an ejb on a server. In this scenario i wrote a message listener class on the client side, i had a start listener method, in which i would do the lookup, create topic connection and start the listener. And the start listener method had to be called/invoked, then only the client would listen to the topic.
If i wanted a MDB to listen to topic, do i need the startlistener method ??
if Yes, who invokes the method ?
if NO, does it mean the MDB is directly bound to the topic ?
Now MDB has an OnMessage() method, in which we write what to do after u get the message ? But my question is how to bind the topic in the first place ?
I know that we can do the settings in the ejb-jar.xml where in you would give the message destination and all. But what about the lookup ? It needs to know the ip address of the topic destination from where it needs to retirieve.
Can some body guide me if i am missing something ?
TIA
Meka Toka
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To bind a MDB to a topic is often done using a deployment tool. Which J2EE application server are you using?
 
meka toka
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using
JBoss 3.0.4
Regards
Meka Toka

PS: A Code snippet will help alot .. thanks
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually it has nothing to do with code, but everything to do with deployment descriptors.
Basically, you need to set the <destination-jndi-name> tag in the MDB's JBoss Descriptor. That's all.
Here is a simple example:

[ February 11, 2003: Message edited by: Chris Mathews ]
 
meka toka
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am new to EJB, so i will put it the way i understand.
I am trying to listen to a remote Topic on a MDB.
Had it been a local topic/queue, i would specify the jndi-detination name and then provide the implementation for onMessage().
If we had to send message on a topic/queue we lookup .. right ? In case of lookup, you will need the context, and for context you need Ip address of the machine on which the topic/queue is hosted.
So if an MDB is subscribing to a remote topic(hosted on another machine), then by just specifying the jndi name, it cant bind itself to the remote topic ... isnt it ?
If i am missing something let me know ?
Thank You
Meka Toka
PS: Did alot of research on net, alot of ppl have same problems, and no post in forums was clear.
 
Chris Mathews
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you are really not asking about Topics at all. What you are asking whether MDBs can listen on remote destinations.
The answer is: yes and no.
It really depends on your Application Server. For example, WebLogic allows MDBs to listen to remote destinations on external JMS Providers. To my knowledge, JBoss does not support this.
In any case, what you really want is a bridge between the remote destination and your local destination. For comparison, WebLogic provides the WebLogic Messaging Bridge for this purpose. On the other hand, JBoss does not provide this feature as part of the Application Server. However, it is fairly easy to write this bridge using a standard JMS Listener and registering it to start on Server Startup. The listener should copy each message recieved from the remote destination to the local destination. You will then configure your MDB to listen on the local destination and you are all set.
 
meka toka
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
That reply was very very helpful. Thanks a million for that. I have been going through a lot of posts, but never found out that Application server provides the functionality so that a MDB can listen to remote topics.
I had implemented the JMS listener as a service, used jmx for that.
But then that thing solved my problem half way.
Situation:
----------
An MDB on a server B needs to listen to a topic on server A. If i did the implementation as above, it means that the listener needs to know the ip address of server B so that it can listen to it.
What if it didnt know and we had to feed it dynamically ?
Appreciate all the help
regards
Meka Toka
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic