Message Outbox for Illuminate
composer require eventsauce/message-outbox-for-illuminate
use EventSauce\MessageOutbox\IlluminateOutbox\IlluminateOutboxRepository;
use EventSauce\MessageOutbox\OutboxMessageDispatcher;
$outboxRepository = new IlluminateOutboxRepository($connection, $tableName, $messageSerializer);
$messageDispatcher = new OutboxMessageDispatcher($outboxRepository);
To ensure dispatching and persisting of messages is done in a single transaction, use the transactional repository wrapper:
use EventSauce\MessageOutbox\IlluminateOutbox\IlluminateTransactionalMessageRepository;
$messageRepository = new IlluminateTransactionalMessageRepository(
$connection,
$innerMessageRepository, // based which uses the same db connection,
$messageSerializer,
);