andreo/eventsauce-outbox

Extended message outbox components for EventSauce.

3.3 2023-03-17 11:41 UTC

This package is auto-updated.

Last update: 2024-11-17 15:26:29 UTC


README

Extended message outbox components for EventSauce

composer require andreo/eventsauce-outbox

Requirements

  • PHP >=8.2
  • Symfony console ^6.2

Previous version docs

Repository without message dispatching

use Andreo\EventSauce\Outbox\Repository\EventSourcedAggregateRootRepositoryForOutbox;

new EventSourcedAggregateRootRepositoryForOutbox(
    aggregateRootClassName: $aggregateRootClassName,
    messageRepository: $messageRepository, // EventSauce\EventSourcing\MessageRepository
    regularRepository: $regularRepository // EventSauce\EventSourcing\AggregateRootRepository
)

Forwarding message consumer

This consumer dispatch messages through the message dispatcher to the queuing system

use Andreo\EventSauce\Outbox\MessageConsumer\ForwardingMessageConsumer;

new ForwardingMessageConsumer(
    messageDispatcher: $messageDispatcher // EventSauce\EventSourcing\MessageDispatcher
)

Command to dispatching messages from the outbox

use Andreo\EventSauce\Outbox\Command\OutboxMessagesConsumeCommand;

new OutboxMessagesConsumeCommand(
    relays: $relays, // Symfony\Component\DependencyInjection\ServiceLocator<EventSauce\MessageOutbox\OutboxRelay>
    logger: $logger, // ?Psr\Log\LoggerInterface
)
php bin/console andreo:eventsauce:message-outbox:consume foo-relay-id

Command options

relays

  • required
  • string[]

Relay ids registered in service locator

--run=true

  • optional
  • default: true

Processing messages run

--batch-size=100

How many messages are to be retrieve batch

  • optional
  • default: 100

--commit-size=1

How many messages are to be committed at once

  • optional
  • default: 1

--sleep=1

Number of seconds to sleep if the repository is empty

  • optional
  • default: 1

--limit=-1

How many times messages are to be processed

  • optional
  • default: -1 (infinity)