Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is it possible to set aside a message and acknowledge it later?

0
Posted

Is it possible to set aside a message and acknowledge it later?

0

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

0

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.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.