RPC flow with RabbitMQ
Difficulty: Hard
Tags: Backend, Messaging, RPC
For this challenge we designed a more complex flow:
- from the page RPC Flow, a call to
/api/rpccallis triggered on load or manually, - the API will send a message into a rabbitmq broker through an exchange named
input.rpcof type 'DIRECT' - in other part, there is a worker located at
./src/worker.tswhich will consume messages in a queuemy.queue.<your-name>. - there should be a binding key
<your-name>that will route message sent through the exchange to land into that queue - once a message is treated successfully, it should reply to the caller (the API) with a response as
result, then the API will send that result in a json response

@todo
Here are what we expect you do:
- configure the broker to have:
- the exchange
input.rpc, type direct- the queue
my.queue.<your-name>, with a binding key<your-name>that supposes to routes messages coming into the axchange into that queue- write the message publisher in
./src/pages/rpccall.ts. You have to fill the functionprocessPayloadand use it- write the consumer in
./src/worker.ts. In this side you have to consume messages received in the queuemy.queue.<your-name>, with parameterexclusive: true, then make sure to respond into the initial caller. What the tis worker is quite simple, it will conver thepayload: stringinto UPPERCASE
Environment
As a broker you can use process.env.RABBITMQ_URL
To run the worker, just launch yarn worker
