pika / pika

Pure Python RabbitMQ/AMQP 0-9-1 client library
https://pika.readthedocs.io
BSD 3-Clause "New" or "Revised" License
3.59k stars 843 forks source link

How do I write a Publisher Confirms by using confirm mode or transactions ? #1212

Closed a523 closed 5 years ago

a523 commented 5 years ago

@potbunker please see https://github.com/pika/pika/commit/61c3fb6ad3961bb3498ad32c70f89e097c0539f2

Originally posted by @lukebakken in https://github.com/pika/pika/issues/1206#issuecomment-486437756

Ya, I have the same problem. but I have another related question . I see this in the rabbitmq's doc:

Using standard AMQP 0-9-1, the only way to guarantee that a message isn't lost is by using transactions -- make the channel transactional then for each message or set of messages publish, commit. In this case, transactions are unnecessarily heavyweight and decrease throughput by a factor of 250. To remedy this, a confirmation mechanism was introduced. It mimics the consumer acknowledgements mechanism already present in the protocol.

I wonder what kind this way is transactional or confirmation mechanism ? if this way is in confirm mode. I see this in the rabbitmq's doc again:

Once a channel is in confirm mode, both the broker and the client count messages (counting starts at 1 on the first confirm.select). The broker then confirms messages as it handles them by sending a basic.ack on the same channel. The delivery-tag field contains the sequence number of the confirmed message. The broker may also set the multiple field in basic.ack to indicate that all messages up to and including the one with the sequence number have been handled.

My question is Where are the client count messages in this code, if this way is in confirm mode? Thanks

lukebakken commented 5 years ago

Hello

Please ask questions on either the rabbitmq-users or pika-python mailing list.

The fastest way to get help is to provide running code that demonstrates the issue you're trying to solve.

There is example code that uses publisher confirms here:

https://github.com/pika/pika/blob/master/examples/confirmation.py

Also, there is a long discussion here that includes code that I will add as an example -

https://groups.google.com/d/msg/rabbitmq-users/-bmUoo0-gMk/tfB7RrlmBQAJ