Skip to content
Advertisement

Laravel Queue Worker, RabbitMQ and running jobs generated remotely

I’ll preface this by admitting slight sleep-deprivation.

The setup is as follows:

API Endpoint (Server A) receives an incoming call, and adds this to a specific queue on the RabbitMQ Server (Server B).

RabbitMQ (Server B) is simply a RabbitMQ Queue Server. Nothing more, nothing less.

Laravel Installation (Server C) is our actual Laravel install, which is meant to look for jobs on specific queues and do things with them.

We have a RabbitMQ package in the Laravel install, which allows the use of the regular Laravel Queue mechanics over a RabbitMQ connection.

The issue I’ve come across is that we can spawn a worker for a queue – but since we’re not generating the jobs passing a $job class (the job content itself is most often a JSON array), the Laravel install has no idea what to do with the job.

So my question revolves mainly around how to approach a scenario like this. I’m thinking that using the Queue-functionality in Laravel won’t do what I need it to do. Can you see an approach that I’m missing? Do I really need to spawn a daemon on a non-framework script to handle this?

Your input is much appreciated!

Advertisement

Answer

The solution is indeed to replicate the job code onto the one issuing the job. The code will not need every dependency that the job requires to actually function, as it only serializes the job from the one pushing it.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement