Commit 217de6ee authored by Federico Sismondi's avatar Federico Sismondi
Browse files

allow lazy MsgReply build, defined correlate_to method to correlate a reply to...

allow lazy MsgReply build, defined correlate_to method to correlate a reply to a request after lazy message build
parent f37a689b
...@@ -80,7 +80,7 @@ import time ...@@ -80,7 +80,7 @@ import time
import json import json
import uuid import uuid
API_VERSION = '0.1.70' API_VERSION = '0.1.71'
# TODO use metaclasses instead? # TODO use metaclasses instead?
...@@ -252,9 +252,17 @@ class MsgReply(Message): ...@@ -252,9 +252,17 @@ class MsgReply(Message):
else: # note this doesnt generate amqp properties else: # note this doesnt generate amqp properties
import logging import logging
logging.warning('(!) messages library | generating reply message without corr_id') logging.warning('(!) messages library | lazy response built, generating reply message without corr_id')
super(MsgReply, self).__init__(**kwargs) super(MsgReply, self).__init__(**kwargs)
def correlate_to(self, request_message):
"""
add to reply message the right correlation information to request
"""
# overwrite correlation id template and attribute
self._properties["correlation_id"] = request_message.correlation_id
self.correlation_id = request_message.correlation_id
class MsgErrorReply(MsgReply): class MsgErrorReply(MsgReply):
""" """
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment