Laravel Queues
Last updated
Was this helpful?
Last updated
Was this helpful?
Ecotone comes with Laravel Queues integration. This means we can use our Queues as for asynchronous communication.
When your you may register it in Ecotone as Asynchronous Message Channel.
We register it using Service Context in Ecotone:
After that we can start using it as any other .
In order to trigger Command
Event
or Query
Handler, we will be sending the Message
via given Ecotone's Bus.
In order to trigger given Bus, inject CommandBus, EventBus or QueryBus (they are automatically available after installing Ecotone) and make use of them to send a Message.
Instead of using queue:work
, we will be running Message Consumer using Ecotone's command:
When sending command and events via routing, it's possible to use non-class types.
Command Handler with command having array payload
In case of sending events, we will be using Event Bus
.
Ecotone deliver copy of the Event
to each of the Event Handlers
, this allows for handling in isolation and safe retries.
Inject Event Bus into your service, it will be available out of the box.
Subscribe to event
By default all your Messages will be serialized using PHP native serialization. However this is not recommended way, as native PHP serialization requires class to be kept the same on deserialization, if we will change the class name, we will fail to deserialize.
If you're using Ecotone JMS, it will automatically set up all your Message Channels to serialize to JSON, as long as you explicitly not state different format.
In case of failures Ecotone's will kick in.
Command Handler inside with command having no payload
at all
We may register our our own different , yet you may use inbuilt solution using , to serialize to JSON without any additional configuration.
Failed transport is configured on Ecotone side using Error Channel. Read more in .