amqp / rhea

A reactive messaging library based on the AMQP protocol
Apache License 2.0
282 stars 79 forks source link

Acknowledgments doesnt work #395

Open sossnowski opened 1 year ago

sossnowski commented 1 year ago

I am trying to implement provider and client data transfer with rabbitmq as a broker. Messages are transferring but I am not able to control if Receiver received it. I tried use autoaccept function to false at the receiver side but Sender side container.on('accepted') event is firing all the time - also when at the receiver side I am adding
container.on('message', (context) => { context.delivery.reject() }); It is changing nothing. Sender fire accepted event even if receiver is not connected! How can I manage? I need to know if messages are reading by clients.

And another question: How to know at the sender side that receiver close connection if there are two applications: client and server - and they are creating own connections with broker?

grs commented 1 year ago

RabbitMQ has a store-and-forward semantic (as do similar alternatives). This means the message is acknowledged when RabbitMQ receives it, not when that message is then forwarded to a consumer.

sossnowski commented 1 year ago

So is it impossible to close client connection to broker (or at least delete queue to force disconnect) using publisher application? I tried achieve it by setting expiry-policy with timeout params, but it doesnt work.

grs commented 1 year ago

So is it impossible to close client connection to broker (or at least delete queue to force disconnect) using publisher application?

You can close the publisher's connection at any time. The AMQP 1.0 specification does not define a way to delete the queue, but brokers often have their own ways of doing this through a message based management protocol. You can ask the RabbitMQ support if they have anything like that.

I tried achieve it by setting expiry-policy with timeout params, but it doesnt work.

That would generally only affect queues that were implicitly created when the publisher attaches I believe.

sossnowski commented 1 year ago

Yes, but closing publisher connection will not imply consumer disconnect from broker queue. Am I right? Connections are independent and Publisher has no power to manage consumer connection with broker?

grs commented 1 year ago

Publisher has no power to manage consumer connection with broker?

Correct. The only way to do that would be through some broker specific management protocol.

sossnowski commented 1 year ago

Thanks a lot.