MessagePublishReceiptListener is not getting the acknowledgement python API

Shijo Member Posts: 10 ✭✭
class SolaceMessagePublishReceiptListener(MessagePublishReceiptListener):
    def __init__(self):
        self._publish_count = 0

    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\
print('SOLACE -- PERSISTENT publisher started')

# adding the message recipient to the publisher
publish_receipt_listener = SolaceMessagePublishReceiptListener()

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?


  • KeganHoltzhausen
    KeganHoltzhausen Member Posts: 4
    edited March 16 #2
    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.
  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 499 admin

    The PublishReceipt encapsulates broker acknowledgement and the MessagePublishReceiptListener 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.