krakend / krakend-amqp

AMQP compatible backend for the KrakenD framework
https://www.krakend.io
Apache License 2.0
10 stars 16 forks source link

amqp producer: static routing_key is ignored #17

Closed plorgue closed 1 year ago

plorgue commented 1 year ago

Hello,

I declare this endpoint, with an amqp producer backend:

      "endpoint": "/chamallows",
      "method": "POST",
      "input_headers": ["*", "Cookie"],
      "backend": [
        {
          "host": ["amqp://guest:guest@rabbitmq:5672"],
          "disable_host_sanitize": true,
          "url_pattern": "/",
          "extra_config": {
            "backend/amqp/producer": {
              "name": "",
              "exchange": "sugar-entrance",
              "durable": true,
              "delete": false,
              "no_wait": false,
              "no_local": false,
              "routing_key": "haribo",
              "mandatory": false,
              "immediate": false
            }
          }
        }
      ]

The routing_key: "haribo" isn't transmitted to rabbitmq. And it seems that only routing_key from url parameters (with capitalization) is working. But in my case I can't use this feature. I don't see this distinctive characteristic in the doc

And I think the reason of that come from this line: https://github.com/krakendio/krakend-amqp/blob/1948b9d0c1465fddb67a88dfe715816666e1a7f6/producer.go#L124

Am I missing something? Is this behavior intentional? If not, is it a problem that can be quickly solved on your side?

Thanks for your work

holyris commented 1 year ago

Did you find a workaround for this ?

kpacha commented 1 year ago

@plorgue yes, that's intended. If you want to use a static, hard-coded value, you can inject a parameter using other components such as a request modifier plugin or a lua snippet.

holyris commented 1 year ago

@plorgue yes, that's intended. If you want to use a static, hard-coded value, you can inject a parameter using other components such as a request modifier plugin or a lua snippet.

Could you give an example for that ?

plorgue commented 1 year ago

@plorgue yes, that's intended. If you want to use a static, hard-coded value, you can inject a parameter using other components such as a request modifier plugin or a lua snippet.

I code an external service that ack messages from the rabbitmq queue that receives krakend payloads and transmit to another exchange with the correct routing-key and with delivery_mode: Persistent (another feature that I need ahah)

That ok for now decause I only have some routes on krakend that publish on rabbitmq so,I configure on rabbitmq exchange by route.

I would look into the request modify plugin or a Lua snippet if I need to scale, thanks for the tips.