Download the PHP package ludovicose/transaction-outbox without Composer
On this page you can find all versions of the php package ludovicose/transaction-outbox. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ludovicose/transaction-outbox
More information about ludovicose/transaction-outbox
Files in ludovicose/transaction-outbox
Package transaction-outbox
Short Description Laravel Pub-Sub package use transactional outbox pattern
License MIT
Homepage https://github.com/ludovicose/transaction-outbox
Informations about the package transaction-outbox
Laravel Pub-Sub package use transactional outbox pattern
When an event is sent to the broker, the event is stored in the database, after which the event is sent to the broker. If the event was successfully sent to the broker, we mark that the event was successfully sent.
When subscribing an event, we listen to the event from the broker. When receiving an event, we store it in the database. After saving to the database, we send an internal event for processing.
The goal of the library is to decide the consistency of data between services, the order in which the message is sent, idempotency.
Currently, the broker is Redis. In the future we will add other brokers message.
Installation
You can install the package via composer:
The package will automatically register itself.
You can publish the migration with:
After the migration has been published you can create the table by running the migrations:
You can publish the config-file with:
Usage
Publish Event
Create event file and implements by ShouldBePublish interface. If the ShouldBePublish interface is implemented, then the event automatically goes to the broker Set channel name. Channel name is the name of the event that will be sent to the broker
To send an event to the broker, you need to run the command
Subscribe
Add a channel name to the config file to understand which event to listen for. These channel names can be used as internal events.
Run command in console t listen event in broker.
Add a channel name to the EventServiceProvider file to listen for the event that came from the broker.
In handle method you get the data that came from the broker
Resubmitting events
If the event did not get into the message broker, then you can resend it with the command below, indicating the start date and end date
Http request
We can also log http requests. When sending a request, we save it with ourselves and upon receiving a response, we note that the request was successfully completed.
To register http requests, you must enable the option in the config file
Resubmitting request
If the http request failed, then it can be resent with the command below, specifying the start date and end date
Resend erroneous data from the queue
If we get an error while processing data from the queue, then this data goes to the queue (serviceName.errors).
To resend data from the queue (serviceName.errors) we need to run the command:
In the configuration file you can specify the name of the queue where the errors will be stored
Clear event in DB
If you do not clean the database from the event, then the entries in the database can increase. To clean up old entries, you can run the command:
In the config file, you can specify a day after which records will be deleted
QUEUE
Add queue.php config rabbitmq
License
The MIT License (MIT). Please see License File for more information.
All versions of transaction-outbox with dependencies
symfony/serializer Version ^6.0
symfony/property-access Version ^6.0
php-amqplib/php-amqplib Version ^3.1