File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Controlling listeners Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Controlling listeners " Watch "Controlling listeners " New topic
Author

Controlling listeners

jimmy coyne
Greenhorn

Joined: Feb 01, 2002
Posts: 8
An Jms object is listening to a queue and is receiving message using the onMessage() method.
What happens if I have a reference to this object and want to call my own method i.e. refresh() , but the queue the object is listening to has 1000 pending messages to process . Will these messages have to be processed before my method is invoked ?At what time does the queue tell the listener that there is a message? ,is it when the queue first retrieves the message or when the message is ready to be sent to the listener .The reason I ask is that, I wish to have some control over my JMS object (pause , stop , refresh etc).
Thanks
Parsuram panigrahi
Greenhorn

Joined: Feb 18, 2003
Posts: 17
I am not quite sure that I got your question. Are you listening to the message from the queue by using an MDB? If so, then the onMessage method comes into work after it recieves the message. So whatever you do in onMessage method is done on the server side and has no effect on the performance of the queue.
jimmy coyne
Greenhorn

Joined: Feb 01, 2002
Posts: 8
No I’m not using a MDB. I have a normal Java class the implements the Messagelistener interface .
When this object is first initialized it reads data from the database for configuration information . The data in the database can change , but I don’t what the class to check the data on every onMessage() .So I want to be able to control this object and call other methods on it , like refresh() . My worry is that if the queue the object is listening to , has 1000+ message to process ,that these messages have to be processed before my method is invoked ?
I hope that’s made it a bit clearer
Thanks
Jim
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Message processing runs on its own thread. If you call refresh() from another thread they will run simultaneously.
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
jimmy coyne
Greenhorn

Joined: Feb 01, 2002
Posts: 8
Originally posted by Kyle Brown:
Message processing runs on its own thread. If you call refresh() from another thread they will run simultaneously.
Kyle

Does that also mean if I have multiple objects that implements the Messagelistener interface , with each object listening to a different queue , that each object can process there messages concurrently. Or do does each class need to extend the Runnable interface and treat as a separate thread?
Thanks
Jim
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Originally posted by jimmy coyne:

Does that also mean if I have multiple objects that implements the Messagelistener interface , with each object listening to a different queue , that each object can process there messages concurrently.

I believe it depends on the messaging vendor, but I'm pretty sure that the answer for all vendors I know of is yes.
Or do does each class need to extend the Runnable interface and treat as a separate thread?
Thanks
Jim

Nope, see the previous.
Kyle
jimmy coyne
Greenhorn

Joined: Feb 01, 2002
Posts: 8
Thanks Kyle , you have been a great help.
Jim
 
 
subject: Controlling listeners