def create_message(): msg = Message(topic) msg.set_keys('XXX') msg.set_tags('XXX') msg.set_property('property', 'test') msg.set_body('message body') return msg
def test_producer_send_orderly_with_sharding_key(orderly_producer): msg = Message('test') msg.set_keys('sharding_message') msg.set_tags('sharding') msg.set_body('sharding message') msg.set_property('property', 'test') ret = orderly_producer.send_orderly_with_sharding_key(msg, 'order1') assert ret.status == SendStatus.OK
def _send_test_msg(producer): msg = Message('test') msg.set_keys('XXX') msg.set_tags('XXX') msg.set_body('XXXX') msg.set_property('property', 'test') ret = producer.send_sync(msg) assert ret.status == SendStatus.OK
def get_msg_instance(topic, body, keys='', tags='', property=None, delay_time_level=0): msg = Message(topic) if keys: msg.set_keys(keys) if tags: msg.set_tags(tags) if property: msg.set_property(property[0], property[1]) if delay_time_level: msg.set_delay_time_level(delay_time_level) body = str(body) # body = bytes(json.dumps(body),encoding="utf8") msg.set_body(body) return msg