🎄 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.

Send json object to Solace queue using Python

The user and all related content has been deleted.
Tagged:

Comments

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 963 admin

    Hi @pr320235,
    Welcome to the Solace Developer Community! When you get a chance it would be great if you could introduce yourself in the intro thread

    As for your question, let me take a shot at it:
    The simplest option for using Python with Solace right now is to use the paho library (docs here, Solace Example Here) which will publish to Solace over the mqtt protocol. Keep in mind that Solace Event Brokers do protocol translation for you so other apps can still receive this messages using other protocols (SMF, AMQP, MQTT, REST, etc.).

    A few other things to keep in mind:
    1. Our best practices recommend publishing to a topic instead of a queue. A queue can then be created for your consumer ( or group of consumers) and have one or many topic subscriptions assigned to it. This allows you to have a better decoupling between your publishers and consumers.
    2. We are currently developing a Python SDK for Solace that will use SMF (Solace Message Format). More info will be coming soon, but in the mean time let me know if you'd like to be involved as an early access reviewer of it.

    Hope that helps!

  • [Deleted User]
    [Deleted User] Posts: 0
    The user and all related content has been deleted.
  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 541 admin

    Hi Praveen!

    For your solace_url param, don’t include the protocol and the port in your url string, so you can do something along the lines of

    url = "<your_domain_name>.solace.cloud"
    username = "solace-cloud-client"
    password = "<password>"
    PORT=1883
    client = mqtt.Client()
    client.username_pw_set(username=username, password=password)
      #      client.on_connect = on_connect
      #      client.on_message = on_message
    client.connect(url, port=PORT )
      #      client.loop_forever()
    

    And a quick side note regarding terminology, using solace you don’t publish to a queue. You connect to the solace broker, publish on a topic and you configure a queue on the broker to subscribe to that topic. Your consuming application will bind to the queue consuming the messages.

    Hope this helps! let me know if it doesn’t work (or if it works too) 😄

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

    Also, i see that you’re a python enthusiast (welcome to the club!) We have some good news coming up with a brand new native Solace Python API which will allow you to do a whole lot more with the broker and access a bunch of functionalities.

    Let me know here if you’re interested to be one of the first to try it out! https://solace.community/discussion/336/python-whos-in-for-a-real-treat

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 963 admin

    To follow up on what @Tamimi said you'll want to use the port specified in your connect info, not the default of 1883.

    Also note that this sample is not configured for using TLS so you'll want to use the MQTT Host info from the Connection Details. Looks like Paho has some TLS options here that you can use to configure TLS

  • [Deleted User]
    [Deleted User] Posts: 0
    The user and all related content has been deleted.