🎄 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 ?
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
Comments
-
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?
0 -
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.
1