Try PubSub+

How to see published messages

pr320235pr320235 Member Posts: 9

Dear All,
I have a python program which publishes data on a topic over MQTT.
program - https://github.com/SolaceLabs/makeuoft-hackathon/blob/master/raspberrypi2solace/publish/virtual_solace_publish_json.py

Where to check published message (in queue or topic)? is there any Dashboard?
How to confirm that message has been received by subscriber?
Thanks,
Praveen Kumar

Comments

  • TamimiTamimi Member, Administrator, Employee Posts: 20 admin
    edited July 29

    Hi Praveen!

    You can indeed check whether your published messages are actually being processed by your broker or not using multiple ways:

    1. PubSub+ Cloud UI: If you are using a broker that is hosted on the cloud, you can navigate to the messaging service cloud management console and click on the "Try Me!" tab

    and from there, you can connect to your broker using the subscriber application

    Once you do that, you can subscribe to any topic you want, so that when your publishing application sends messages to the broker on that topic you can see it. Tip you can leverage Solace Wildcards so you can just subscribe to devices/> which will let the subscribing application receive all messages sent on devices/.../..../...

    1. PubSub+ Management UI: if you are connecting to a local software version of the broker (e.g. using a docker), you can access the broker management console and navigate to the "Try Me!" tab


    and do the same thing in step 1

    1. You can build your own subscribing application using python and mqtt! Run the following python subscriber program in a separate terminal while your publishing application is running:
    import paho.mqtt.client as mqtt
    import json
    
    def on_connect(client, data, flags, rc):
        assert (rc == 0), "Error Connecting. Return code: " + str(rc)
        client.subscribe("device/#")  #NOTE: The MQTT wildcard '#' is the same as the Solace '>' wildcard
    
    def on_message(client, data, msg):
        msg_json_object = json.loads(msg.payload.decode('ascii'))
        msg_json_pretty = json.dumps(msg_json_object, indent=2)
        print("Received message on: %s\n %s" % (msg.topic, msg_json_pretty))
    
    # Broker Info
    url = <host url>
    username = 
    password = 
    
    client = mqtt.Client()
    client.username_pw_set(username=username, password=password)
    client.on_connect = on_connect
    client.on_message = on_message
    client.connect(url)
    client.loop_forever()
    

    Let me know if you want more input on this, hope this helps. @pr320235

  • amackenzieamackenzie Member, Employee Posts: 38 Solace Employee

    also, you are publishing with QoS1 which is a guaranteed message in PubSub+. If the publisher got an acknowledgment from the broker, it was successful.

  • pr320235pr320235 Member Posts: 9

    Thanks @Tamimi for detailed explaination. I was able to check my messages using "Try-me" option in dashboard.
    Thank you very much for you support.

    Warm Regards,
    Praveen Kumar
    @pr320235

Sign In or Register to comment.