laravel-queue-rabbitmq
laravel-queue-rabbitmq copied to clipboard
[Feature] Laravel Jobs with RPC
Why RPC ?
Sometimes you need to inform or to do something, in a 3th-party application and return the result. This can be done by calling an Api (synchronous) or asynchronous when your not interested when the job is processed and don't need an immediate reply.
The later is called RPC and here is the specification. Rpc is a common pattern and with a message broker like RabbitMQ, jobs are made asynchronous. See the example.
Why in this library ?
This lib is fully integrated into the laravel Queue API. Everything works the laravel way. Ofcourse we can write a new library for RPC with laravel. but why should we. In the end, we endup with almost an exact copy with on-top an extra feature.
Overall overview Feature
Process
- Job builds a payload with extra keys in the payload (rpc_version, method, params)
- Job is dispatched to an alternate exchange or queue directly (queue the remote application listens for messages)
- Remote method with parameters is processed by the remote server/worker
- Remote server/worker sends a 'copy' of the original message with extra added keys in the payload, to the reply queue. (old headers, old payload with the key result or error)
- Job is (finally) picked up by a laravel worker and handled (processes the result or error).
Terms
- A job must indicate if it is a job for RPC
- When a job is a RpcJob, the normal queue becomes the reply-to queue
- A RpcJob must provide the remote Procedure with its params.
- A job can provide configuration for dispatching to an exchange or queue.
- In the connection config, default configuration can be set for all RpcJobs.
:+1: if you like the feature
would be very nice
@adm-bome I am new to laravel and I want to use RPC using this package. And of-course I have seen the process but I didn't get it. So please could you demonstrate it with example. Thank you.
Do we have a package for laravel to handle RPC protocol? @adm-bome
I'm going to close this issue. The purpose of the library is not to provide an RPC framework. There are many RPC frameworks out there and you will see that they usually grow quite large as you want to handle retries, timeouts, resiliency etc...