DEV Community

Chrysovalanto Kousetti
Chrysovalanto Kousetti

Posted on

10 1

Sending a RabbitMQ message with JSON payload using curl

If you are working with RabbitMQ in a deployed environment you will often not have access to the RabbitMQ web UI which allows you to send test messages to try things out. Here is an example curl you can use adapting it to your needs to send a JSON payload message via RabbitMQ.

Things to replace:

  • USERNAME: The RabbitMQ user's username
  • USERPASSWORD: The RabbitMQ user's password
  • QUEUE_NAME: The queue to publish to
  • ENCODED_JSON_PAYLOAD: The JSON payload. Make sure this is stringified (I just do a quick javascript console: JSON.stringify({"my_json": "payload"}) that does the trick)
curl -s -u USERNAME:USERPASSWORD -H "Accept: application/json" -H "Content-Type:application/json" -X POST -d'{
    "vhost": "/",
    "name": "amq.direct",
    "properties": {
        "delivery_mode": 2,
        "headers": {}
    },
    "routing_key": "QUEUE_NAME",
    "delivery_mode": "1",
    "payload":"ENCODED_JSON_PAYLOAD",
    "headers": {},
    "props": {},
    "payload_encoding": "string"
}' http://localhost:15672/api/exchanges/%2F/amq.direct/publish


Enter fullscreen mode Exit fullscreen mode

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more