MessagePublishReceiptListener is not getting the acknowledgement python API
Shijo
Member Posts: 10 ✭✭
class SolaceMessagePublishReceiptListener(MessagePublishReceiptListener): def __init__(self): self._publish_count = 0 @property def get_publish_count(self): return self._publish_count def on_publish_receipt(self, publish_receipt: 'PublishReceipt'): with lock: self._publish_count += 1 print(f"\tSOLACE -- \n", f"\tMessage: {publish_receipt.message}\n", f"\tIs persisted: {publish_receipt.is_persisted}\n", f"\tTimestamp: {publish_receipt.time_stamp}\n", f"\tException: {publish_receipt.exception}\n") if publish_receipt.user_context: print(f'\tUsercontext received: {publish_receipt.user_context.get_custom_message}')
used the receipt listener by:
publisher= messaging_service.messaging_service\ .create_persistent_message_publisher_builder().build() publisher.start() print('SOLACE -- PERSISTENT publisher started') # adding the message recipient to the publisher publish_receipt_listener = SolaceMessagePublishReceiptListener() publisher.set_message_publish_receipt_listener(publish_receipt_listener)
messages published synchronously
publisher.publish_await_acknowledgement(outbound_message, topic, 2000)
However, after publishing the message successfully, we are not getting any acknowledgment from the listener.
Anyone tried this receipt listener in the solacePubSub python API?
Tagged:
0
Comments
-
Are you expecting the listener to Ack when it has consumed the message back to the publisher? As that is not how message level acknowledging works.
The ACK in this context, is is between the broker and the client ( publisher OR listener ), but not end to end between the listener and the publisher. That is more a request-reply pattern.
When a client publishes, the ACK is between the client and the broker. The broker is acknowledging that it has received the message and persisted per the properties.
When the listener ( client ) consumes the message from the broker, the listener will ACK back to the broker that it has successfully processed the message. This ACK is again only regarding the transport of the message and there is no propegation back to the producer.
If you want to know from the producer side when a message was processed, you need to use RequestReply, and reply from the listener with a specific acknowledgement schema of your choice.0 -
The
PublishReceipt
encapsulates broker acknowledgement and theMessagePublishReceiptListener
is an interface to process broker message publish notifications. On the receiver side you can build your persistent message receiver with message client ack. You can read more about different acknowledgement options with the Python API in the reference documentation.0