-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
I'm trying to understand how to implement an api gateway that deals with microservices that expose rest and rpc endpoints.
- Expose REST endpoints to the client. Internally route to the REST or RPC microservices
- Expose REST and RPC endpoints to the client, route as necessary
We chose Krakend, I implemented the endpoints and configured rabbitmq, and it works, but I don't know how to give to the correct client from the queue. Can I give it back with some key?
@kpacha
first way
here i try set username with a queue and return the new username
{
"endpoint": "/api/v1.0/setUserName/{reply_to}/{mess_id}/{route}",
"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",
"method": "GET",
"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",
"reply_to_key":"Reply_to",
"msg_id_key":"Mess_id",
"routing_key":"Route"
}
}
}
]
},
second way
producer
here i try set username with a queue
{
"endpoint": "/api/v1.0/setUserName/{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"
}
}
}
]
},
consumer
here return the new username
{
"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": true,
"delete": false,
"exclusive": false,
"internal": false,
"no_wait": true,
"no_local": false,
"routing_key": "Route",
"prefetch_count": 10
}
}
}
]
}
thanks for help)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels