amqpextra icon indicating copy to clipboard operation
amqpextra copied to clipboard

Confirmation buffer on shutdown

Open Crevil opened this issue 4 years ago • 5 comments

Thank you for adding support for publish confirmations in #43 and #44. I have a question regarding how the buffer is handled during shutdown.

Say there are 10 messages in-flight waiting for confirmation in the confirmation buffer and we call cancel the context passed to the dialer in amqpextra.NewDialer(amqpextra.WithContext(ctx)).

Will the close call block until confirmations has been received or timed out or will we abort right away?

I wasn't able to find some documentation around this and I couldn't see any tests that tests that?

Crevil avatar Jan 12 '21 14:01 Crevil

I suppose It should send amqp.ErrClosed to all pending messages, wait till it is done and exit.

Ideally you should stop publishing, wait till all pending messages are published and confirmed and only after call publisher.Close()

makasim avatar Jan 12 '21 15:01 makasim

I gave it another though and It looks like there is room for improvement. Here https://github.com/makasim/amqpextra/blob/master/publisher/publisher.go#L365 we can catch graceful stop and give some time for messages to catch up.

makasim avatar Jan 12 '21 15:01 makasim

Yes, that would make good sense. It would be nice with a timeout on the last catch up part, as to be able to indicate how long one is willing to wait for the issue to resolve.

Crevil avatar Jan 12 '21 15:01 Crevil

Ideally you should stop publishing, wait till all pending messages are published and confirmed and only after call publisher.Close()

How would I check if there are any messages still in-flight?

nilathedragon avatar Nov 03 '21 17:11 nilathedragon

By closing contexts in proper order. You have some inputs and outputs in your app, and a pipeline in between. So, you have to start stopping the app from inputs and go to outputs.

makasim avatar Nov 03 '21 19:11 makasim