Skip to content

Commit

Permalink
Merge pull request #1301 from pika/mk-message-metadata-access-example
Browse files Browse the repository at this point in the history
Demonstrate how to access consumer metadata
  • Loading branch information
michaelklishin committed Jan 26, 2021
2 parents fbe3c41 + f0d897f commit adf89f3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions examples/consume.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
'-35s %(lineno) -5d: %(message)s')
LOGGER = logging.getLogger(__name__)

logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)


def on_message(chan, method_frame, _header_frame, body, userdata=None):
def on_message(chan, method_frame, header_frame, body, userdata=None):
"""Called when a message is received. Log message and ack it."""
LOGGER.info('Userdata: %s Message body: %s', userdata, body)
LOGGER.info('Delivery properties: %s, message metadata: %s', method_frame, header_frame)
LOGGER.info('Userdata: %s, message body: %s', userdata, body)
chan.basic_ack(delivery_tag=method_frame.delivery_tag)


Expand Down

0 comments on commit adf89f3

Please sign in to comment.