def publish_byte_message_non_blocking(message_publisher: PersistentMessagePublisher, destination: Topic, message): """method to publish byte message using persistent message publisher, non-blocking""" publish_receipt_listener = MessagePublishReceiptListenerImpl() message_publisher.set_message_publish_receipt_listener(publish_receipt_listener) message_publisher.publish(message, destination) time.sleep(2) print(f'Publish receipt count: {publish_receipt_listener.get_publish_count}\n')
def publish_string_message_non_blocking(message_publisher: PersistentMessagePublisher, destination: Topic, message): """method to publish string message using persistent message publisher, non-blocking""" publish_receipt_listener = MessagePublishReceiptListenerImpl() message_publisher.set_message_publish_receipt_listener(publish_receipt_listener) message_publisher.publish(message, destination) print(f'PERSISTENT publish message is successful... Topic: [{destination.get_name()}]') time.sleep(2) print(f'Publish receipt count: {publish_receipt_listener.get_publish_count}\n')
def publish_typed_message_non_blocking(message_builder: OutboundMessageBuilder, message_publisher: PersistentMessagePublisher, destination: Topic, message): """method to publish typed message using persistent message publisher, non-blocking""" publish_receipt_listener = MessagePublishReceiptListenerImpl() message_publisher.set_message_publish_receipt_listener(publish_receipt_listener) message = message_builder.build(payload=message, converter=PopoConverter()) message_publisher.publish(message, destination) time.sleep(2) print(f'Publish receipt count: {publish_receipt_listener.get_publish_count}\n')
def correlate_message_on_broker_ack_with_user_context_non_blocking \ (message_builder: OutboundMessageBuilder, message_publisher: PersistentMessagePublisher, destination: Topic, message): """method to publish message using persistent message publisher and ack with user context, non-blocking""" publish_receipt_listener = MessagePublishReceiptListenerImpl() message_publisher.set_message_publish_receipt_listener(publish_receipt_listener) message = message_builder.with_priority(255).build(payload=message, converter=PopoConverter()) message_publisher.publish(message=message, destination=destination, user_context=BasicUserContext('hello')) time.sleep(2) print(f'Publish receipt count: {publish_receipt_listener.get_publish_count}\n')
def publish_typed_message_with_extended_message_props_non_blocking(message_builder: OutboundMessageBuilder, message_publisher: PersistentMessagePublisher, destination: Topic, message, additional_message_properties=None): """method to publish typed message with extended properties using persistent message publisher, non-blocking""" publish_receipt_listener = MessagePublishReceiptListenerImpl() message_publisher.set_message_publish_receipt_listener(publish_receipt_listener) message = message_builder.with_priority(255).build(payload=message, converter=PopoConverter()) if additional_message_properties: message_publisher.publish(message, destination, additional_message_properties=additional_message_properties) else: message_publisher.publish(message, destination) time.sleep(2) print(f'Persistent Message Sent: Publish receipt count: {publish_receipt_listener.get_publish_count}\n')