Skip to content

Commit

Permalink
Update documentation for mandatory flag with BlockingConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebakken committed Apr 24, 2019
1 parent 42ca6d0 commit 61c3fb6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions docs/examples/blocking_publish_mandatory.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Ensuring message delivery with the mandatory flag
=================================================

The following example demonstrates how to check if a message is delivered by setting the mandatory flag and checking the return result when using the BlockingConnection::
The following example demonstrates how to check if a message is delivered by setting the mandatory flag and handling exceptions when using the BlockingConnection::

import pika
import pika.exceptions

# Open a connection to RabbitMQ on localhost using all default parameters
connection = pika.BlockingConnection()
Expand All @@ -14,16 +15,17 @@ The following example demonstrates how to check if a message is delivered by set
# Declare the queue
channel.queue_declare(queue="test", durable=True, exclusive=False, auto_delete=False)

# Enabled delivery confirmations
# Enabled delivery confirmations. This is REQUIRED.
channel.confirm_delivery()

# Send a message
if channel.basic_publish(exchange='test',
routing_key='test',
body='Hello World!',
properties=pika.BasicProperties(content_type='text/plain',
delivery_mode=1),
mandatory=True):
try:

This comment has been minimized.

Copy link
@churruscat

churruscat May 1, 2020

Missing indentation

This comment has been minimized.

Copy link
@lukebakken

lukebakken May 1, 2020

Author Member

This is open-source, please submit a pull request if you think something should be changed.

channel.basic_publish(exchange='test',
routing_key='test',
body='Hello World!',
properties=pika.BasicProperties(content_type='text/plain',
delivery_mode=1),
mandatory=True):

This comment has been minimized.

Copy link
@jssuzanne

jssuzanne May 7, 2019

You should remove ":" at the end of the line

This comment has been minimized.

Copy link
@lukebakken

lukebakken May 1, 2020

Author Member

This is open-source, please submit a pull request if you think something should be changed.

It is very unlikely someone will ever notice a comment on a single commit. It's only by chance I saw this one.

print('Message was published')
else:
except pika.exceptions.UnroutableError:
print('Message was returned')

0 comments on commit 61c3fb6

Please sign in to comment.