• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Controlling listeners

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Message processing runs on its own thread. If you call refresh() from another thread they will run simultaneously.
Kyle
 
jimmy coyne
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Kyle , you have been a great help.
Jim
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic