How to use the guranteed publisher

Options
sulfred
sulfred Member Posts: 20

Hi all,

I am trying out the guranteed_publisher.py: https://github.com/SolaceSamples/solace-samples-python/blob/master/patterns/guaranteed_publisher.py

There is a callback on_publish_receipt: https://github.com/SolaceSamples/solace-samples-python/blob/master/patterns/guaranteed_publisher.py#L43

I see that is the confirmation from Solace. I also see that the callback is around 100 ms delayed.

I can imagine an use case is that the publisher should get the confirmation before it is going to send another message. Given that there is a 100 ms delay, it seems that this is not reasonable to do that.

  • I would like to ask what is the use case of this callback

Thanks.

Best Answer

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 491 admin
    edited March 2022 #2 Answer ✓
    Options

    the on_publish_receipt is a callback function defined in the MessagePublishReceiptListener class. You access this on the API level. You can think of Management vs Messaging APIs when using Solace as follows

    • Use the Management API for broker management such as setting configuration, creating resources, setting access rights...etc. Note that You have three ways to do this: CLI, SEMP API, Web based Gui. Step 3 in this codelab highlights the three main ways to manage configuration on the broker https://codelabs.solace.dev/codelabs/solace-event-enable-rest/index.html?#3
    • Use the Messaging API for all things messaging. So for example, if you want to interact with sending/receiving messages or checking on_publish_receipt for guaranteed messages. You can leverage any Solace messaging API or open standard protocols for this

    Using Guaranteed messaging

    For best practices, this is how we recommend implementing guaranteed messaging with Solace:

    1. Create a queue on the broker
    2. Add topic subscriptions to it
    3. Publish on topics --> queue will attract the message
    4. Consumer binds to queue
    5. Process the message on the consumer and explicitly send an acknowledgement after successful processing
    6. The message will be deleted from the queue when an acknowledgement is received

    Taking our Python API as an example, the publisher publishes messaged on a topic (https://github.com/SolaceSamples/solace-samples-python/blob/master/patterns/guaranteed_publisher.py#L96) and the consumer binds to an existing queue on the broker (https://github.com/SolaceSamples/solace-samples-python/blob/master/patterns/guaranteed_subscriber.py#L73-L76)

    Hands-on resources

    I recommend checking out our collection of codelabs on https://codelabs.solace.dev/. There are a bunch of step by step tutorials to using different Solace features, integration guides, and use-cases examples.


    Hopefully this helps! Let me know if you have any follow up questions :)

Answers

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 491 admin
    Options

    Hey @sulfred ! A note about sending Guaranteed messages in Solace, as per this section in the documentation

    When Guaranteed messages are published, and there are no Guaranteed subscriptions on the event broker that match the messages’ topics, the event broker can either:


    - Return negative acknowledgments (that is, “Nacks”) to the publishers to indicate that there are no matching Guaranteed subscriptions for the messages. Messages published to unknown queue names are always Nacked.


    - Silently discard the messages (that is, no Nacks are returned to the publishers). This is the default action.

    so the so the received PublishReceipt by the API will not have any exceptions if the broker successfully received the message regardless if there were subscriptions to the message or not. If you explicitly enable the send nacks on no subscription, the the receipt received on on_publish_receipt will have an exception (publish_receipt.exception) that you can further explore and act on.

    Not sure where the 100 ms delay is, I ran it locally and go the receipt immediately from the broker. Note that I am testing locally on my machine.

  • sulfred
    sulfred Member Posts: 20
    Options

    Hi @Tamimi ,

    Thanks for the reply, I will look into that and try again. The setting on_publish_receipt , is it a setting on CLI?


    #1

    A further question, I am now trying to do a guaranteed publishing and consuming communication. I would like to ask where can I find an example that is showing the preferred use case suggested from Solace?

    As you may realized, I am following that python example from the github, guaranteed_publisher.py and guaranteed_consumer.py . I created the durable message queue on the web portal. Is it already a preferred way to correctly using this communication pattern?


    #2

    Is there any documentation or tutorial or course that can go through a several key features on Solace web portal and CLI ? I mean I can see the documentation from here, it is explaining the concepts clearly but I would like to see how to link up the concepts and the implementation.

    For example:

    • How to use the management web portal.
    • How to manage the Client profile, VPN, Disaster Recovery setting etc...
    • Monitoring on the portal: direct message, guaranteed message

    Thanks

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 491 admin
    edited March 2022 #5 Answer ✓
    Options

    the on_publish_receipt is a callback function defined in the MessagePublishReceiptListener class. You access this on the API level. You can think of Management vs Messaging APIs when using Solace as follows

    • Use the Management API for broker management such as setting configuration, creating resources, setting access rights...etc. Note that You have three ways to do this: CLI, SEMP API, Web based Gui. Step 3 in this codelab highlights the three main ways to manage configuration on the broker https://codelabs.solace.dev/codelabs/solace-event-enable-rest/index.html?#3
    • Use the Messaging API for all things messaging. So for example, if you want to interact with sending/receiving messages or checking on_publish_receipt for guaranteed messages. You can leverage any Solace messaging API or open standard protocols for this

    Using Guaranteed messaging

    For best practices, this is how we recommend implementing guaranteed messaging with Solace:

    1. Create a queue on the broker
    2. Add topic subscriptions to it
    3. Publish on topics --> queue will attract the message
    4. Consumer binds to queue
    5. Process the message on the consumer and explicitly send an acknowledgement after successful processing
    6. The message will be deleted from the queue when an acknowledgement is received

    Taking our Python API as an example, the publisher publishes messaged on a topic (https://github.com/SolaceSamples/solace-samples-python/blob/master/patterns/guaranteed_publisher.py#L96) and the consumer binds to an existing queue on the broker (https://github.com/SolaceSamples/solace-samples-python/blob/master/patterns/guaranteed_subscriber.py#L73-L76)

    Hands-on resources

    I recommend checking out our collection of codelabs on https://codelabs.solace.dev/. There are a bunch of step by step tutorials to using different Solace features, integration guides, and use-cases examples.


    Hopefully this helps! Let me know if you have any follow up questions :)

  • sulfred
    sulfred Member Posts: 20
    Options

    Hi Tamimi,

    Thanks for the detail instructions. I created the durable queue on the broker with the desired topic subscriptions. It works.

    Thanks for the other learning materials, I will read them one by one.