noodlefrenzy / node-amqp10

amqp10 is a promise-based, AMQP 1.0 compliant node.js client
MIT License
134 stars 56 forks source link

Question: What to do on receive link detach #304

Open jeffmcaffer opened 7 years ago

jeffmcaffer commented 7 years ago

In our app processing time for a messages varies significantly. As such we buffer up messages from the queue and when a worker is ready, one of the buffered messages is taken. When the message has been processed, the worker accepts the message. Given a renew on settled policy, that triggers an additional credit and a new message is received and added to the buffer. All is good.

Question is, when the receiveLink is detached, what should we be doing with the buffered messages? They are locked on the server and sitting in memory on the client. We can just keep them and process but what will happen when the get accepted? I'm assuming the link's credit goes to 0 on detach or rather, back to creditLimit when the link reattaches. That will cause the queue to receive creditLimit more messages. But in actual fact, the client has (up to) 2*creditLimit messages and will accept each one.

If we clear out the messages, then they are locked on the server and will not be redelivered for (in our case) 5 minutes. Since the link is down, we can't release them (or can we?). We could release on reattach but that is starting to get complicated.