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.