Message Outbox for Doctrine 3
composer require eventsauce/message-outbox-for-doctrine
use EventSauce\MessageOutbox\DoctrineOutbox\DoctrineOutboxRepository;
use EventSauce\MessageOutbox\OutboxMessageDispatcher;
$outboxRepository = new DoctrineOutboxRepository($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\DoctrineOutbox\DoctrineTransactionalMessageRepository;
$messageRepository = new DoctrineTransactionalMessageRepository(
$connection,
$innerMessageRepository, // must use the same db connection
$outboxRepository, // as this outbox
);