I have a requirement where in if service (Restful service) I call from message driven bean is down or does not return success, I need to rollBack message back to queue, wait for some time(exponentially) and then read message again from queue and try connecting to service.
What I am trying:
Within the OnMessage
method, in case I receive an exception from the service which is calling the Restful service, I am rolling back using messageDrivenContext.setRollBackOnly()
and I can do something like Thread.sleep(RETRY_WAIT_TIME)
;
But how do I make sure that RETRY_WAIT_TIME
is increased exponentially?
Probably I need to maintain state of the bean, but can anyone please suggest how I can do that?