aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes JMS timed redelivery Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JMS timed redelivery" Watch "JMS timed redelivery" New topic
Author

JMS timed redelivery

Java Buzz
Greenhorn

Joined: Mar 11, 2005
Posts: 10
Hi,
I am using JMS topic(websphere default JMS) to notify some consumers. The consumers have to process and push the data to other external systems. Sometimes the external systems might be down temoporarily, in which case I need to redeliver the message to the consumer.

Which is the most elegant way of implementing this.
Regards,
Hari
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10289
    
168

Sometimes the external systems might be down temoporarily


If your consumers are MDBs:
Will the consumers be able to identify whether the external system is down? If yes you can call the setRollbackOnly method on the message driven context which will tell the server to redeliver the message.

In case your consumers are not MDBs, then you can use CLIENT_ACKNOWLEDGEMENT on the session which sends the messages(producer). And whenever the consumer finds the external system down he will send a failure acknowledgement which will tell the server to redeliver the message.

However the problem with both these approaches will be, you cannot tell the container after what interval the message should be redelivered. It might so happen that when the message is redelivered the external system might still be down.


[My Blog] [JavaRanch Journal]
Java Buzz
Greenhorn

Joined: Mar 11, 2005
Posts: 10
Hi,
The consumers are MDB's in my case. And regarding the retries I want to retry only three times max, with a time difference of 5 mins. So it is like after first attempts, rety attempts will be made at 5th, 10th and 15th min. If this is the requirement, then how can I go about?
Regards,
Hari
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10289
    
168

BTW, welcome to Javaranch. Please change your name to abide by the Naming Policy at Javaranch
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10289
    
168

I want to retry only three times max, with a time difference of 5 mins.


I am sure you can specify the retry limit. However what i am not sure is whether you can specify the time difference between these retries. I have seen such a thing in JBoss but not aware about Websphere. You might have to check the Websphere documentation to see if its possible.
Java Buzz
Greenhorn

Joined: Mar 11, 2005
Posts: 10
I checked the documentatin of both Websphere default JMS and the websphere MQ. Both of them doesn't seem to provide. Weblogic 9.2 offers. In my case, I need to design some thing on my own to implement the same.

I had been searching about this for the past 6 hours. There are so many "weird" implementations being suggested. But I am looking for a cleaner one.

*Note - The same question has been raised on some forum way back in 1999
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10289
    
168

In my case, I need to design some thing on my own to implement the same.


Other than the one which i mentioned in my first reply, nothing comes to mind, which can help you in this requirement.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10289
    
168

On second thoughts, how about this (not so elegant) approach:

1) Your consumer(MDB) identifies that the external system is down
2) This MDB will schedule a job(which will start 5 min from now) using a Scheduler(there are open source schedulers like Quartz which you can use). The MDB will pass the message(which it received in its onMessage method) as a parameter to the scheduled job.
3) The onMessage method of this MDB will return normally, so that the message is removed from the queue and will NOT be redelivered.

Now after 5 minutes, the scheduled job is invoked and it receives the message as the parameter. The responsibility of this scheduled job will be to put the message back to the original queue so that it is delivered to the MDB by the server.

I cant say what all issues you might encounter while trying to get this working, since i haven't tried this sort of a thing myself. Also this does not look like a elegant solution to me - you can add this to those "weird" implementations, which you mention, you have already seen. I would rather prefer the application server providing me a feature like "redelivery interval" for redelivering the messages.
Java Buzz
Greenhorn

Joined: Mar 11, 2005
Posts: 10
Jaikiran,
This seems to be more viable solution. I will try this and will post if I face any issue in this approach.

Thanks !

~Hari
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JMS timed redelivery