# Send json object to Solace queue using Python

**URL:** <https://community.solace.com/t/send-json-object-to-solace-queue-using-python/337>\
**Category:** General Discussions\
**Tags:** python\
**Created:** [July 23, 2020, 3:39pm UTC](https://community.solace.com/t/send-json-object-to-solace-queue-using-python/337 "2020-07-23T15:39:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/solace/original/1X/1248f38eea018157e66cc024e8284f3331a54f94.png) [@system](https://community.solace.com/u/system)\
**Post date:** [July 23, 2020, 3:39pm UTC](https://community.solace.com/t/send-json-object-to-solace-queue-using-python/337/1 "2020-07-23T15:39:47Z")

</div>

The user and all related content has been deleted.

---

<div class="post-metadata">

**Author:** ![marc](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/marc/32/2191_2.png) [@marc](https://community.solace.com/u/marc)\
**Post date:** [July 23, 2020, 4:43pm UTC](https://community.solace.com/t/send-json-object-to-solace-queue-using-python/337/2 "2020-07-23T16:43:38Z")

</div>

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](https://community.solace.com/discussion/307/introductions-thread-new-to-the-community-start-here)

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](https://www.eclipse.org/paho/clients/python/docs/), [Solace Example Here](https://github.com/SolaceLabs/makeuoft-hackathon/blob/master/raspberrypi2solace/publish/virtual_solace_publish_json.py)) 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!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/solace/original/1X/1248f38eea018157e66cc024e8284f3331a54f94.png) [@system](https://community.solace.com/u/system)\
**Post date:** [July 28, 2020, 11:01am UTC](https://community.solace.com/t/send-json-object-to-solace-queue-using-python/337/3 "2020-07-28T11:01:35Z")

</div>

The user and all related content has been deleted.

---

<div class="post-metadata">

**Author:** ![Tamimi](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/tamimi/32/2190_2.png) [@Tamimi](https://community.solace.com/u/Tamimi)\
**Post date:** [July 28, 2020, 12:10pm UTC](https://community.solace.com/t/send-json-object-to-solace-queue-using-python/337/4 "2020-07-28T12:10:55Z")

</div>

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

```auto
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) ?

---

<div class="post-metadata">

**Author:** ![Tamimi](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/tamimi/32/2190_2.png) [@Tamimi](https://community.solace.com/u/Tamimi)\
**Post date:** [July 28, 2020, 12:16pm UTC](https://community.solace.com/t/send-json-object-to-solace-queue-using-python/337/5 "2020-07-28T12:16:15Z")

</div>

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! [Python! Who's in for a real treat? — Solace Community](https://community.solace.com/discussion/336/python-whos-in-for-a-real-treat)

---

<div class="post-metadata">

**Author:** ![marc](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/marc/32/2191_2.png) [@marc](https://community.solace.com/u/marc)\
**Post date:** [July 28, 2020, 12:34pm UTC](https://community.solace.com/t/send-json-object-to-solace-queue-using-python/337/6 "2020-07-28T12:34:34Z")

</div>

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](https://www.eclipse.org/paho/clients/python/docs/) that you can use to configure TLS

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/solace/original/1X/1248f38eea018157e66cc024e8284f3331a54f94.png) [@system](https://community.solace.com/u/system)\
**Post date:** [July 31, 2020, 11:17am UTC](https://community.solace.com/t/send-json-object-to-solace-queue-using-python/337/7 "2020-07-31T11:17:18Z")

</div>

The user and all related content has been deleted.
