Preserve all properties when wrapping Pika message. Closes #48. Thanks to dgorissen

This commit is contained in:
Ask Solem 2011-07-15 11:41:23 +01:00
parent 8628adbd84
commit 897fec6728
1 changed files with 12 additions and 0 deletions

View File

@ -10,6 +10,8 @@ Pika transport.
"""
import socket
from operator import attrgetter
from kombu.exceptions import VersionMismatch
from kombu.transport import base
@ -26,16 +28,26 @@ from pika.spec import Basic, BasicProperties
DEFAULT_PORT = 5672
BASIC_PROPERTIES = ("content_type", "content_encoding",
"headers", "delivery_mode", "priority",
"correlation_id", "reply_to", "expiration",
"message_id", "timestamp", "type", "user_id",
"app_id", "cluster_id")
class Message(base.Message):
def __init__(self, channel, amqp_message, **kwargs):
channel_id, method, props, body = amqp_message
propdict = dict(zip(BASIC_PROPERTIES,
attrgetter(BASIC_PROPERTIES)(props)))
kwargs.update({"body": body,
"delivery_tag": method.delivery_tag,
"content_type": props.content_type,
"content_encoding": props.content_encoding,
"headers": props.headers,
"properties": propdict,
"delivery_info": dict(
consumer_tag=getattr(method, "consumer_tag", None),
routing_key=method.routing_key,