• 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
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Configuring Delay in reading JMS Message

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

I am consuming JMS message in my application (NOT deployed in an application Server).

However as a step forward to the current application, we need to add in some delay in between 2 messages which are read from Queue. For eg. normal flow is as follows

1. Read a message from Queue.
2. Process the message
3. Ack the JMS Queue
4. Again Read the message.

Now after step 3 and before step 4, I need to wait for some time.
Now is there any property in JMS which can do this?
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can set a delay in delivery on the queue. It is non-standard but most JMS vendors support it. Will that do?

ram.
 
Gagan Tiwari
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many thanks Sir,

But I don't see any property in Queue to set this.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I mentioned in my previous post, it does not form part of the JMS api. You will have to look at the documentation for the JMS provider you use.
In weblogic for example, you can set it programmatically



Here is the javadoc for weblogic.

cheers,
ram.
 
Gagan Tiwari
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ramprasad,

This I suppose we are talking in terms of PRODUCER (Means once you create a message and then sets its property)

Whereas I am looking into the Consumer part,to add delay while consuming messages, as messages are pumped in by another application.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
javax.jms.Connection.stop() temporarily stops a connection's delivery of incoming messages.

ram.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The other option is to use the receive() method of the QueueReceiver in place of the MessageListener.

So your code would go something like below (pseudo-code)

for(;;){
Message m = queueReceiver.receive();
//processMessage();
Thread.sleep(timeInterval); //now pause
}

cheers,
ram.
 
pie. 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