• Post Reply Bookmark Topic Watch Topic
  • New Topic

Configuring Delay in reading JMS Message

 
Gagan Tiwari
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • 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?
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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 Java Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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 Java Tomcat Server
  • Mark post as helpful
  • send pies
  • 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 Java Tomcat Server
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!