twingly / twingly-amqp

:bus: Ruby gem for RabbitMQ subscribing and publishing
0 stars 0 forks source link

Wait for messages correctly in specs #102

Closed roback closed 11 months ago

roback commented 11 months ago

We use publisher confirms in our specs to wait for messages to be handled before we continue with the tests. However, I think that we have assumed that the publisher waits for the messages to be acknowledged by a consumer (like we do in the specs above), but that's not the case according to the documentation:

When Will Published Messages Be Confirmed by the Broker? [...] For routable messages, the basic.ack is sent when a message has been accepted by all the queues. For persistent messages routed to durable queues, this means persisting to disk. For quorum queues, this means that a quorum replicas have accepted and confirmed the message to the elected leader.

The publisher just waits for the RabbitMQ server to persist the message the relevant queues, not for the consumers to consume/acknowledge it.

This might be why I'm seeing some test failures when experimenting with quorum queues in #100, and also why we've seen a few intermittent test failures in other projects, for example https://github.com/twingly/dawson/issues/225 (although that doesn't happen that often).

Originally posted by @roback in https://github.com/twingly/twingly-amqp/issues/86#issuecomment-1755329556