def consume_message(<EOL>method):
def wrapper(<EOL>self,<EOL>channel,<EOL>method_frame,<EOL>header_frame,<EOL>body):<EOL><INDENT>sys.stdout.write("<STR_LIT>".format(body))<EOL>sys.stdout.flush()<EOL>try:<EOL><INDENT>body = body.decode("<STR_LIT:utf-8>")<EOL>data = json.loads(body)<EOL>method(self, data)<EOL><DEDENT>except Exception as exception:<EOL><INDENT>sys.stderr.write("<STR_LIT>".format(traceback.format_exc()))<EOL>sys.stderr.flush()<EOL><DEDENT>channel.basic_ack(delivery_tag=method_frame.delivery_tag)<EOL><DEDENT>return wrapper<EOL>
Decorator for methods handling requests from RabbitMQ

The goal of this decorator is to perform the tasks common to all
methods handling requests:

- Log the raw message to *stdout*
- Decode the message into a Python dictionary
- Log errors to *stderr*
- Signal the broker that we're done handling the request

The method passed in will be called with the message body as a
dictionary. It is assumed here that the message body is a JSON string
encoded in UTF8.