🎄 Happy Holidays! 🥳

Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.

Happy Holidays!

Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.

Synchronous publish in python ?

uherbst
uherbst Member, Employee Posts: 130 Solace Employee
edited March 2023 in General Discussions #1

Hi all,


what is the easiest, most clean code to publish ONE guaranteed message in python and only proceed after the ACK from the broker has arrived ?


(I know, that this usage pattern is not performant, if I have many messages to publish. My use is different).


Thank you

Uli

Tagged:

Comments

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 541 admin

    Hey @uherbst if you want to only wait for an ack from the broker that it received the message you can simply use publish_await_acknowledgement and you can use it as follows:

    publisher.publish_await_acknowledgement(outbound_msg, topic)

    was this what you were looking for?

  • tiwaabh
    tiwaabh Member Posts: 5

    Hi @Tamimi - I am looking for the same thing in node.js. I need to await the ack/nack of published message. Currently I am using solclient.js. Any suggestions?

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 644 admin

    Just thought I'd post up my suggestion here for consideration: if looking to publish just one message, wait for confirm, and then disconnect, why not use the REST Messaging API? Just POST your message to the broker on the correct REST port (default 9000), with the topic as the URL, and the body as the payload. When you get the 200 OK, you know it's been successfully received by the broker. This just seems easier than creating a connection, waiting for connection, publishing message, waiting for acknowledgement, then disconnecting.

    Note: using a message broker for "one at a time" messaging is kind of an anti-pattern. As setting up the connection (TCP, TLS, etc.) is kind of expensive. Typically an app would connect, stay connected, and do lots of pubbing and subbing during its lifetime.

This Week's Leaders