Laravel Microservices

166 views
Skip to first unread message

Andreas Noutsopoulos

unread,
Oct 31, 2022, 8:24:30 AM10/31/22
to rabbitmq-users
I have a web application. The front end is written in React.
    There is the API gateway which is where the front end requests arrive, first stop.
   
    Then this api gateway talks to multiple microservices (i.e. other laravel apps).
    I want to use RabbitMQ between my api gateway and all other microservices around it.
   
    I want to use RabbitMQ locally, I have a server just for this application and the microservicesare hosted on the same server.
    So, I did manage to set up RabbitMQ locally. I have managed to add messages (with data -as array) from the API gateway (my producer) to the RabitMQ queue. I can see the messages in the RabitMQ management.
    Question: How do I read a message with its data at the receiver end?
    Question: How do I reply to the producer with data?
   
I have been looking at it 3 days now and I can't find something really useful other than those plain examples that run with manual commands (sorry, but these are almost useless). 

Do you have a clear example of that in Laravel? An example following best practices.
Do I keep connections open, do I not? What should I do and what I should NOT! 

Please can you help?

Andreas Noutsopoulos

unread,
Nov 1, 2022, 3:10:43 AM11/1/22
to rabbitmq-users

Ok, I was very frustrated when I posted this, I found out few stuff. I am new to laravel you see. I only figured out that in order to keep the queue running you should started in a terminal and keep it there running. Is that correct? So when I am on a server environment there will be a terminal constantly open(?) actually as many terminals as the queues. So if I connect to 20 microservices that talk on different queues there will be 20 terminals? 

I had seen your tutorials but I didn't expect I would have to have a process running through a terminal forever and I was looking for something different... 

If you don't reply to newcomers to rabbitMQ please let me know so I don't waste my time here, or with rabbitMQ even! Actually you can delete this post even...

Thank you.

Santiago Acosta

unread,
Nov 2, 2022, 3:41:15 PM11/2/22
to rabbitm...@googlegroups.com
A backend is a daemon process running on a server. It is supposed to be on "forever" (except when you take it down for maintenance or it crashes). We do not usually run our backend services in terminals unless we are testing for something specific. We set the daemon up as a "service" process, and configure it so that it may start on OS restart and add some graceful shutdown routines so that it may coordinate on a power-off. RabbitMQ is supposed to run as a service as well.

You use Laravel which is a PHP framework that although you might think is only "activating" when a user request shows up, the daemonic process behind your implementation is actually an HTTP Daemon (like Apache's httpd, NginX, or Microsof's IIS). These daemons respond to user requests by running your scripts (in this case Laravel's) on every request (an httpd worker will run a child process that will execute the PHP binary with the target files, this is usually what we configure once in our *.conf files and forget until we need to tweak it).

AFAIK, the Laravel team may have implemented some kind of daemonic process that would keep a daemon thread alive "forever" as some kind of make-shift backend (I think they have some kind of Chron job implementation which would theoretically run as a scheduler daemon). It is possible that they may have other features that would resemble what you are looking for.

However, as you can see, your question has very little to do with RabbitMQ and I don't know if this is the right place to be asking these questions. You would find better help with the Laravel community if you are going to stick with their solutions and features.

Andreas Noutsopoulos

unread,
Nov 3, 2022, 3:20:43 AM11/3/22
to rabbitmq-users
Thank you for you response!
It helps a lot in many aspects!

Reply all
Reply to author
Forward
0 new messages