1

I am using the REST API http://192.168.99.100:32787/api/exchanges/%2f/amq.direct/publish to publish a message to my helloworld.q queue.

Payload:

{"properties":{},"routing_key":"","payload":"Hello World","payload_encoding":"string"}

I have not created any new exchanges. I wasn't sure which exchange to specify hence used amq.direct in the rest url. I have already provided the Basic Auth credentials and I am getting following response from the API.

{
    "routed": false
}

Not sure what's wrong.

The latest documentation on how to use it's HTTP API can be found here. https://rawcdn.githack.com/rabbitmq/rabbitmq-management/rabbitmq_v3_6_11/priv/www/api/index.html

1
  • Nothing in your request or properties indicates the queue to which the message should be published. How did you ever expect it to work with a direct exchange?!?! Commented Nov 17, 2018 at 15:10

1 Answer 1

5

You have two ways to make that work:

  • Either you use the default exchange and specify your queue name as routing key (otherwise RabbitMQ has no clue regarding which queue you want your message to go):

    POST /api/exchanges/%2f//publish HTTP/1.1 {"properties":{},"routing_key":"helloworld.q","payload":"Hello World","payload_encoding":"string"}

  • Or you explicitly send it to the amq.direct exchange but then you have to create a binding between helloworld.q and amq.direct before publishing the message. The routing key of the message you publish will have to match the one you specify on the binding too.

Sign up to request clarification or add additional context in comments.

1 Comment

This didn't work for me because the queue didn't already exist. ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.