STOMP - Python

Updated on 20 Sep 2023

I am using the Python stomp.py library to send a message

#!/usr/bin/env python3

import stomp
import sys

if len(sys.argv) > 1:

    conn = stomp.Connection(vhost='demo_host')
    conn.connect('demo_user', 'demo_pass', wait=True)
    conn.send(body=sys.argv[1], destination='/queue/q1')
    conn.disconnect()

Sending the message

I will also make this file executable, and to call this code, I simply do the following.

./send.py "hello world from Python"

Rabbitmqadmin

I can use rabbitmqadmin to check the message

rabbitmqadmin list vhosts

And to see the message, I can use the following command.

rabbitmqadmin get queue=q1 --vhost=demo_host -u guest -p guest

I am using guest username because I have assigned the appropriate privileges to that account.