def on_sendable(self, event): message = Message(body=json.dumps(self.message)) # We have to manually set this - Proton won't do it for us message.creation_time = time.time() print(message) event.sender.send(message) event.sender.close()
def zaqar_to_proton(message): """Convert a message retrieved from storage to a Proton message""" msg = Message() msg.ttl = message.get('ttl') msg.body = message.get('body') # NOTE(vkmc) This won't work for now - there is no 'amqp10' field yet if message.get('amqp10'): msg.priority = message.get('amqp10').get('priority') msg.first_acquirer = message.get('amqp10').get('first_acquirer') msg.delivery_count = message.get('amqp10').get('delivery_count') msg.id = message.get('amqp10').get('id'), msg.user_id = message.get('amqp10').get('user_id') msg.address = message.get('amqp10').get('address') msg.subject = message.get('amqp10').get('subject') msg.reply_to = message.get('amqp10').get('reply_to') msg.correlation_id = message.get('amqp10').get('correlation_id') msg.content_type = message.get('amqp10').get('content_type') msg.content_encoding = message.get('amqp10').get('content_encoding') msg.expiry_time = message.get('amqp10').get('expiry_time') msg.creation_time = message.get('amqp10').get('creation_time'), msg.group_id = message.get('amqp10').get('group_id') msg.group_sequence = message.get('amqp10').get('group_sequence') msg.reply_to_group_id = message.get('amqp10').get('reply_to_group_id') msg.format = message.get('amqp10').get('format') return msg
def on_sendable(self, event): if not self.sent: msg = Message() msg.address = self.address msg.id = '123455' msg.user_id = BINARY('testuser') msg.subject = 'test-subject' msg.content_type = 'text/html; charset=utf-8' msg.correlation_id = 89 msg.creation_time = 1487772623.883 msg.group_id = "group1" msg.reply_to = 'hello_world' msg.content_encoding = 'gzip, deflate' msg.reply_to_group_id = "group0" application_properties = dict() application_properties['app-property'] = [10, 20, 30] application_properties['some-other'] = symbol("O_one") msg.properties = application_properties msg.body = u"Hello World!" event.sender.send(msg) self.sent = True
def on_sendable(self, event): if not self.sent: msg = Message() msg.address = self.address msg.id = '123455' msg.user_id = 'testuser' msg.subject = 'test-subject' msg.content_type = 'text/html; charset=utf-8' msg.correlation_id = 89 msg.creation_time = 1487772623.883 msg.group_id = "group1" msg.reply_to = 'hello_world' msg.content_encoding = 'gzip, deflate' msg.reply_to_group_id = "group0" application_properties = dict() application_properties['app-property'] = [10, 20, 30] application_properties['some-other'] = symbol("O_one") msg.properties = application_properties msg.body = u"Hello World!" event.sender.send(msg) self.sent = True