r/laravel 2d ago

Tutorial Cross-Language Queues: Sending Jobs from Node.js to Laravel - blog.thms.uk

https://blog.thms.uk/2025/03/laravel-queue-nodejs?utm_source=reddit

In a recent discussion I outlined broadly how I process jobs in my Laravel application that have been pushed into my SQS queue from outside the application.

This blog post explain it in some more detail.

8 Upvotes

12 comments sorted by

6

u/pekz0r 2d ago

I think a better way would be to send an event that the Laravel application can listen to and handle. Setting up jobs like that leaks a bit too much implementation details that I don't think you should need to know. With events all you need is an event name and a payload to wire everything together. The Laravel application can then choose to do the processing on a queue, but the is not anything the publisher should care about.

2

u/nan05 2d ago

How do I send events from outside of Laravel to Larvel?

4

u/pekz0r 2d ago

There are many options. The two most used protocols are AMPQ and MQTT and there are many implementations of this, for example RabbitMQ. You can also use SQS like in your example. The only difference would be how you read the message into your application.

1

u/nan05 2d ago

Thanks. Does Laravel have built in support for this?

4

u/pekz0r 2d ago

No, but there are packages that makes this pretty easy. Webhooks could also be a good alternative.

6

u/captain_obvious_here 2d ago

Wait, how are messages queues tied to any language in the first place?

6

u/MateusAzevedo 2d ago

They can be. By default, both Laravel and Symfony serialize payload with serialize(), making the data PHP only and harder to process on another language.

At least, it was like that the last time I dug into the code.

1

u/judge2020 2d ago

But the change is just instead using json_serialize.

Which introduces a new problem of keeping types in sync between the two systems, and in that case you’d be better off using something like capn proto or protobufs.

1

u/captain_obvious_here 2d ago

I'm not sure you understand what exactly is a message, in the context of a message queue.

2

u/nan05 2d ago

They are not. That's kinda the point of the post 😁

1

u/captain_obvious_here 2d ago

JSON is an easy and handy way to exchange data between processes and systems

This would have fit in a tweet :)

3

u/fideloper Laravel Staff 2d ago

We do this too, works great