Observation-Management-Service / MQClient

A Message Queue Client API Supporting Apache Pulsar, RabbitMQ, and NATS.io
MIT License
0 stars 1 forks source link

Document Examples & Patterns #96

Open ric-evans opened 1 year ago

ric-evans commented 1 year ago

Let's document a list of "known working patterns" and "known problematic patterns".

One problematic problem is separating the QueueSubResource's context manager and iterator in a loop. For example:

while True:
    async with from_clients_queue.open_sub() as sub:
        ... other stuff that takes a while ...
        async for msg in sub:
            process(msg)

On RabbitMQ this will raise a ConnectionResetError: [Errno 104] Connection reset by peer error. It could be resolved by increasing the heartbeat timeout (which is controlled by ack_timeout, but this is a complex problem--best to avoid)