3

Can anyone help me with setting up rabbitmq in krakend, I have a big problem when I try to get a message in kraken from the queue and pass it to the client?

The scheme is as follows:

  1. client-> API gateway (krakend) -> queue (rabbitmq) -> service

And vice versa when answering:

  1. service -> queue (rabbitmq) -> API gateway (krakend) -> client

For example, we received a request from a client - "Get a list of products from some service", the api gateway(krakend) accepts it and sends it to the queue (rabbitmq), at the end, the service that listens to the queue receives a message and sends the list of products in response to another queue, and kraken should take this data and transfer it to the client (here I don't know how kraken should transfer data to our client).

link to doc https://www.krakend.io/docs/backends/amqp/

I tried to implement this in two ways, but did not get the result that I needed

First way

  1. My producer(here i get the request post with url parameters. Reply_to parameter is the name of new queue in which i will wait the answer in krakend) here i put the request on the queue.
{
  "endpoint": "/api/v1.0/goodsList/{reply_to}/{mess_id}/{route}",
  "method": "POST",
  "headers_to_pass": ["Content-Type"],
  "backend": [
    {
      "host": [
        "amqp://guest:guest@rabbitMQ:5672/"
      ],
      "sd": "static",
      "encoding": "json",
      "disable_host_sanitize": true,
      "extra_config": {
        "github.com/devopsfaith/krakend-amqp/produce": {
          "name": "queue",
          "exchange": "exchange",
          "durable": true,
          "delete": false,
          "exclusive": false,
          "no_wait": true,
          "mandatory": true,
          "immediate": false,
    
          "reply_to_key":"Reply_to",
          "msg_id_key":"Mess_id",
          "routing_key":"Route"
        }
      }
    }
  ]
},

  1. My consumerhere i want to give a name and route for a new queue in order to create it and start listening(consume) and to give data to the client upon request
{
  "endpoint": "/api/v1.0/consumer/{queue_name}/{route}",
  "method": "GET",
  "backend": [
    {
      "host": [
        "amqp://guest:guest@rabbitMQ:5672/"
      ],
      "sd": "static",
      "encoding": "json",
      "disable_host_sanitize": true,
      "extra_config": {
        "github.com/devopsfaith/krakend-amqp/consume": {
          "name": "Queue_name",
          "exchange": "exchange2",
          "durable": false,
          "delete": false,
          "exclusive": true,
          "internal": false,
          "no_wait": true,
          "no_local": false,
          "routing_key": "Route",
          "prefetch_count": 10
        }
      }
    }
  ]
}

Second way

{
      "endpoint": "/api/v1.0/goodsList",
      "method": "POST",
      "output_encoding": "json",
      "extra_config": {
        "github.com/devopsfaith/krakend/proxy": {
          "sequential": false
        }
      },
      "backend": [
        {
          "host": [
            "amqp://guest:guest@rabbitMQ:5672/"
          ],
          "url_pattern": "/",
          "encoding": "json",
          "sd": "static",
          "disable_host_sanitize": true,
          "extra_config": {
            "github.com/devopsfaith/krakend-amqp/consume": {
              "name": "queue",
              "exchange": "exchange",
              "durable": true,
              "delete": false,
              "exclusive": false,
              "no_wait": true,
              "no_local": false,
              "routing_key": [
                "#"
              ],
              "prefetch_count": 10
            },

            "github.com/devopsfaith/krakend-amqp/produce": {
              "exchange": "exchange2",
              "durable": true,
              "delete": false,
              "exclusive": false,
              "no_wait": true,
              "mandatory": true,
              "immediate": false,
              "name": "queue2"
            }
          }

        }
      ]
    }

what is the correct way to implement an exchange between a client and a server in krakend using amqp(rabbitMQ)?

Thanks for the help.

Murad
  • 29
  • 1

1 Answers1

0

Its not supported by Krakend right now. Anyone who is interested in that kind of functionality can keep following this ticket