问题
I am sending the SOAP messages to external service using webservice call. Sometimes external webservice is down so I don't want to lose those failed messages. I push those failed messages to one jms queue designated as retry queue.
Now my requirement is that I have to implement a mechanism to process failed messages from retry queue after some time(lets say half an hour) and try to deliver again to webservice. I should be using fix number of attempts at the interval of half an hour. If I don;t succeed after fixed number of attempts, I should put the message in dead letter queue.
I need help in implementing this requirement.
As the initial step in this direction, I tried use jms polling on retry queue and set the polling interval half an hour. This jms polling jobs wakes up every half an hour and process all the messages present in retry queue. The drawback with this approach is, it tries to redeliver the failed message as soon as it receives for the first time. For subsequent messages, it works fine. Due to this when some message is failed and I put that message in retry queue, it tries to redeliver that message immediately.
来源:https://stackoverflow.com/questions/17838222/retry-jms-queue-implementation-to-deliver-failed-messages-after-certain-interval