Help with Curl and api call to publish message to a queue #14328
-
Community Support Policy
RabbitMQ version used4.1.2 Erlang version used27.3.x Operating system (distribution) usedWindows Server How is RabbitMQ deployed?Other rabbitmq-diagnostics status outputSee https://www.rabbitmq.com/docs/cli to learn how to use rabbitmq-diagnostics Logs from node 1 (with sensitive values edited out)See https://www.rabbitmq.com/docs/logging to learn how to collect logs Logs from node 2 (if applicable, with sensitive values edited out)See https://www.rabbitmq.com/docs/logging to learn how to collect logs Logs from node 3 (if applicable, with sensitive values edited out)See https://www.rabbitmq.com/docs/logging to learn how to collect logs rabbitmq.confSee https://www.rabbitmq.com/docs/configure#config-location to learn how to find rabbitmq.conf file location Steps to deploy RabbitMQ clusterI'm not responsible for deploying it. Steps to reproduce the behavior in questionHi, I'm trying to publish an XML file to a queue via Curl but can't quite get the command correct. If I publish via the front end on http://MyRabbit:15672/#/queues/MyVhost/MyQueue I simply paste the XML in and hit publish. I think I may be using the wrong api call but this is what I'm trying - curl -s -u user:password -H "Accept: application/xml" -H "Content-Type:application/xml" -X POST -d @payload.xml http://MyRabbit:15672/api/exchanges/MyVhost/MyQueue/publish This is the error I get - {"error":"not_found","reason":"exchange_not_found"} What's the correct syntax for publishing to a queue via Curl/api as I would via the front end? Thanks. advanced.configSee https://www.rabbitmq.com/docs/configure#config-location to learn how to find advanced.config file location Application code# PASTE CODE HERE, BETWEEN BACKTICKSKubernetes deployment file# Relevant parts of K8S deployment that demonstrate how RabbitMQ is deployed
# PASTE YAML HERE, BETWEEN BACKTICKSWhat problem are you trying to solve?Hi, I'm trying to publish an XML file to a queue via Curl but can't quite get the command correct. If I publish via the front end on http://MyRabbit:15672/#/queues/MyVhost/MyQueue I simply paste the XML in and hit publish. I think I may be using the wrong api call but this is what I'm trying - curl -s -u user:password -H "Accept: application/xml" -H "Content-Type:application/xml" -X POST -d @payload.xml http://MyRabbit:15672/api/exchanges/MyVhost/MyQueue/publish This is the error I get - {"error":"not_found","reason":"exchange_not_found"} What's the correct syntax for publishing to a queue via Curl/api as I would via the front end? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
The key question here is whether Another question to ask: in AMQP 0-9-1, do you publish directly to queues? No, you don't, you publish to an exchange, in particular the management UI form uses the virtual hosts's default exchange which makes it look like you were publishing to a queue. Publishing over the HTTP API is greatly discouraged. If you have to do it, use # "amq.default" is a way to reference the default exchange that the HTTP API supports
# to avoid confusing empty strings used by AMQP 0-9-1 clients
rabbitmqadmin --vhost "/" publish message --exchange "amq.default" --routing-key "qq.1" --payload '{"type": "example"}'If a queue named
if the queue does not exist and the message cannot be routed anywhere, the output will say as much: The The above commands produce an HTTP API request that looks like so: and the response is Please take it from here. |
Beta Was this translation helpful? Give feedback.
The key question here is whether
MyQueueis an exchange. It's not. So why do you expect RabbitMQ to treat a queue as if it was an exchange?Another question to ask: in AMQP 0-9-1, do you publish directly to queues? No, you don't, you publish to an exchange, in particular the management UI form uses the virtual hosts's default exchange which makes it look like you were publishing to a queue.
Publishing over the HTTP API is greatly discouraged. If you have to do it, use
rabbitmqadminv2: