Is it possible to set aside a message and acknowledge it later?
There are no special primitives for doing this. Here are two possible solutions. One approach is to use multiple sessions as in the following: while (true) { Create a session, subscribe to one message on durable subscription Close session Save session reference in memory To acknowledge the message, find the session reference and call acknowledge() on it. } Another solution is to use transactions and suspend the work as follows: start transaction while(true) { message = receive(); if (message is one that I can handle) process the message commit } else { suspend transaction put transaction aside with message start transaction } } To “acknowledge” the message: resume user transaction commit To “recover” the message: resume user transaction rollback Each time you suspend, you need to push the transaction onto a stack or list possibly with the message so you can process it or roll it back later. This solution is high overhead in that there can be a large build up of outstanding transactions
A. There are no special primitives for doing this. Here are two possible solutions. One approach is to use multiple sessions as in the following: while (true) { Create a session, subscribe to one message on durable subscription Save session reference in memory To acknowledge the message, find the session reference and call acknowledge() on it. } Another solution is to use transactions and suspend the work as follows: start transaction while(true) { message = receive(); if (message is one that I can handle) process the message commit } else { suspend transaction put transaction aside with message start transaction } } To “acknowledge” the message: resume user transaction commit To “recover” the message: resume user transaction rollback Each time you suspend, you need to push the transaction onto a stack or list possibly with the message so you can process it or roll it back later. This solution is high overhead in that there can be a large build up of outstanding transactions.