Hi Anjali,

The jms service does not work by passing message listeners to the server,
instead the messages are passed back from the jms server to your client and
the message listener code is always executed on your client machine.

If you want the message listener code to be executed on the server you need
to run your JMS client that uses the message listener on your server
machine.

When you call setListener() a new thread is started on your client machine
which sends a request to the JMS server for a message, waits for the
message, executes the onMessage() method of your message listener and then
loops by requesting another message, getting the message, executing the
onMessage() method etc.

Cheers
David

> -----Original Message-----
> From: chauhan anjali [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 30, 2001 6:51 PM
> To: [EMAIL PROTECTED]
> Subject: [JBoss-dev] how to call MessageListener
> 
> 
> I have to call the onMessage Method of my
> messageListener when the message arrives at the queue.
>   The messageListener and the Server are on the
> different machines. 
> So I guess the messageListener should be passed by
> Referance .If it has to be passed by refearnce we
> should use RMI. But From the source code it doesn't
> appear so. 
> So is there any other way to do this.
> Can anybody told me how this is acheived.
> 
> Regards,
> Anjali
>   
> 
> 
> 
> 
> My  server is running on  machine1.
> We have a class  Test which implements 
> MessageListener on another machine2.
> /****************/
> import java.io.*;
> import javax.jms.*;
> public class Test implements MessageListener
> ,Serializable
> {
>    Test()
>     { 
>       System.out.println("in test()");
>     }
> 
>     public void onMessage(javax.jms.Message message)
>     {
>       System.out.println("in onMessage of brijesh
> machine()");
>      }
> 
> } 
> /********************************/
> 
> and a receiver programme which is also   running on 
> machine2 . The test is set for this listener. 
> /*********/
> Test  test  = new Test();
> receiver.setMessageListener(test);
> /**************/
>   I want to know how the JMS server hand over the
> message object  to the perticular messageListener (
> test)
>   The server must be having either the test with it or
> a referance of the test on machine2.
> So  how the messge listener(test) object is passed  to
> the server , by referance or by value?
> 
> The System.out.println statement in the onMessage() of
> test t gets printed on the  machine2.
> I guess if it is passed by value then print statement
> should be get printed on machine1 and if it is passed
> by referance then it should be get printed on machine2
> .But from the source code I 
> could not get any clue so as to How it is being passed
> by referance? 
> 
>     So could anybody tell  me  how exactly the
> setListener() works.
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Get email alerts & NEW webcam video instant messaging with 
> Yahoo! Messenger
> http://im.yahoo.com
> 
> _______________________________________________
> Jboss-development mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-development
> 

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to