Is there any way to introduce a delay to the redelivery of rolled-back messages?
I have a MessageListener() that could potentially rollback a Session if a service it needs to connect to is unavailable. If this service goes down, it will generally stay down for some period of seconds. I'd prefer to not have the message redelivered immediately.
Would just calling Thread.sleep(15000) be a reasonable solution? E.g.:
onMessage(Message message) {
try {
callExternalService(message); // throw Exception on failure
session.commit();
}
catch (Exception ex) {
Thread.sleep(15000);
session.rollback();
}
}
Thanks in advance.
That sounds like a reasonable thing to do. You might want to send an admin message or at least log somewhere what's going on. You wouldn't want to find the queue filling up and not know why the connected client isn't consuming the messages.
Thanks.
One other thing: does Sonic 7.5+ have any mechanism for doing this through configuration like some other brokers do? Either a specific delay period or some configurable back-off algorithm?
At this stage, there is no inbuilt mechanism for doing this. The client could be coded to not receive messages if it's not ready to deal with them, but that's just a different way of doing what you suggested. The solution you suggested will take a little more overhead on the JMS side (rolling back the messages), but might be easier or more efficient for the other side of dealing with the message.
A couple of other people have asked about similar functionality before, so if it's something you think really needs to get into the product, it'd be a good idea to call Tech Support and register an enhancement request. The more people that say they want a feature, the more likely it'll get implemented.