tjoskar's avatar

AMQP with laravel

Hi,

I'm thinking of building an API application that work something like this: – At front I have a NodeJS app (Express or Sails.js or similar) which is only a thin and dumb layer that receives http requests and forwards it to an Laravel app.

Has anyone here worked with AMQP (and laravel) and could point me in the right direction? I found this repo: https://github.com/forumhouseteam/laravel-amqp but it seems that it only uses the queue functionality, not the possibility to communicate between apps.

The reason why I want to use NodeJS and Laravel is:

  1. NodeJS is fast
  2. Today I have NodeJS side by side with laravel (apache proxy). It would be nice to only have one application accessible by HTTP.
  3. I already have written a big amount of business logic in laravel and I want to keep that.
  4. I like the idea of Micro Service Architecture
  5. I want to learn
0 likes
6 replies
tjoskar's avatar

Hi xsmall,

I don't know if you misunderstand my question or if I misunderstand your answer. I want to find a way to communicate between laravel instance and node js (without HTTP). Sure, I could establish a websocket connection between a node js instance and laravel with Larapush but it feels backwards.

I saw, however, that Larapush is using ZeroMQ and that maybe the way to go for me. Thanks for that!

kunandrei's avatar

Hi there,

I did the same thing a while ago, while we started with a JSON API written in Lumen but also we wanted to have real time chat . All those solutions in PHP for real time communications where not so good and we finally choosed Socket.IO.

For that, we created a small instance of nodeJS with express framework and added socket.io on both Client(Browser) and Server (NodeJs)

Real time communication was in place, but we also wanted to save messages into Database and since Lumen is already linked to our MySQL instance, we had to find a way of communication bidirectional between NodeJs and Lumen.

Redis can do that. It's really fast and light because it's just a key value cache system.

We implemented also a publish subscriber pattern to immediate react when some value is changed in Redis for specific key. So implementing both a subscriber and a published on both Lumen/Laravel and NodeJS will bring you the benefit of pushing data from/to Lumen and NodeJs.

Please do more research on Redis.

Thanks.

kabacs's avatar

You can do that with Redis and PUB/SUB.

aachich's avatar

I know this is old, but for future reference, here's a library that easily allows for easy AMQP (RabbitMQ and other abstractions) communication: rachid-aachich/laravel-amqp-broker

Please or to participate in this conversation.