Replies: 2 comments 1 reply
-
@phroggyy Leo For readers like me, I fear that you are assuming more knowledge than I have as to what you are looking to achieve and what the current issues are.
|
Beta Was this translation helpful? Give feedback.
-
You can either have 2 queues - one for each direction. Or if Laravel and other technology solutions implement both broadcast and receive functionality, then you can transfer information in both directions. But the fundamental difference between these two is that Queues are guaranteed delivery - if the receiver is down, the request is not lost. Broadcast isn't - if the receiver is down, the message will be gone. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This relates to #42181 and is an expansion on it as a more complete idea.
Background
Microservices are becoming more and more prevalent, and even without them, it is somewhat common to have more than one Laravel app to build out your complete app. I currently work with microservices, but have likewise previously worked with a company providing multiple products that sometimes had to interact.
Asynchronous communication via a message broker is generally more reliable than direct calls. I've previously solved this by building a library that abuses the queue system (https://github.com/decahedronio/laravel-app-events) and later a compatible library in Go (https://github.com/jobilla/go-app-events).
Use case
Asynchronous communication between multiple applications, helps improve system reliability and response time when expensive operations are required. Works effectively like a multi-application queue-system.
Why this should be in laravel/framework
There's an argument to be made for just creating a package of this and I think there are good reasons for it. However, the widespread adoption of Laravel would make it easier for developers to build compatible packages for other languages, and the Laravel umbrella guarantees a level of quality and reliability that may be essential to these systems. Further, it may make sense to extend one of the existing systems (queue or event), in which case adding it to core makes sense.
Requirements
Proposed solution
The current event system would map to the new
sync
topic, akin to Laravel's system. Just like the queue system, we may then introduce an artisan command, either mapping to the topic/subscriber terminology, or event/listener terminology:artisan topic:subscribe {topic} {--subscriber=}
orevents:listen
with the same signature.--subscriber
would allow overriding the name of the subscriber (used by message brokers to determine delivery). Thesubscriber
would default to eitherconfig('app.name')
or perhaps it could all be determined by an option in a new config file,config/events.php
, which would look something likeOne thing that is not 100% clear to me is how overriding serialisation and deserialisation should work, and what extensions would be required to
Event
payloads to support it. Perhaps they can be kept as plain as now and it's up to each serialiser to enforce interface fulfilment (e.g by shipping/relying on aSerializesJson
interface, which could be part of Laravel or 3rd party).Beta Was this translation helpful? Give feedback.
All reactions