I am using KrakenD as an API gateway and I want to send input HTTP requests from KrakenD to a RabbitMQ server. I want to get the name of the queue from the request header and create the queue if it does not exist. I am using the AMQP producer component of KrakenD to connect to RabbitMQ.
I have the following configuration for my KrakenD endpoint:
{
"endpoint": "/produce",
"method": "POST",
"backend": [
{
"host": [
"amqp://guest:guest@rabbitmq:5672"
],
"disable_host_sanitize": true,
"extra_config": {
"backend/amqp/producer": {
"name": "{{.Headers.queue}}",
"exchange": "some-exchange",
"durable": true,
"delete": false,
"no_wait": true,
"routing_key": [
"#"
],
"auto_delete": false,
"exclusive": false,
"backoff_strategy": "exponential-jitter"
}
}
}
]
}
I am sending a POST request to the /produce endpoint with a header queue: test-queue and a JSON body {"message": "Hello world"}. I expect KrakenD to send the message to the test-queue in RabbitMQ and create the queue if it does not exist.
It seems that KrakenD is not creating the exchange or the queue for me. How can I fix this? Do I need to create the exchange and the queue manually before sending the request? Is there a way to make KrakenD create them dynamically?