0

As mentioned in Laravel docs (http://laravel.com/docs/5.1/events#defining-listeners), I can make a listener to be queued. This makes it possible to run events in an asynchronous manner.

I went more deep into this, and found out that I can even have the event to be fired in a separate Laravel installation, as long as they use the same queue instance(beanstalkd in my case) and they also share the same listener (the listener class should be defined in both installations).

Now I need some more information regarding this.

  1. Is this OK? I mean, it works for now, but is it considered a "hack"? Is there any library or another way for this?
  2. How can I have distributed events using this? I mean, when I fire an event somewhere, there will be some listeners that will be fired somewhere else. They are not on the same installation, and all of them has to be fired. This is not achievable with my current setup.

I think I'm looking for some distributed event system with Laravel, but I'm not sure...

1 Answer 1

1

You don´t need a queue to achieve this. I had similar problem that you and I solve this at this way:

  1. If you want to send events to your frontend on any machine I recommend you use Broadcasting events. You can use Redis or Pusher.
  2. If you want to send events to your backend on any machine you need to use Redis Sub/Pub. You send a event from any place (PUBlisher) and you need in each machine a listener to get this event (SUBscribers).

I use too Beanstalkd to distribute jobs in several instances. Works like a charm!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.