Conversation
|
|
||
| } | ||
|
|
||
| public function process(Message $message): Message|null |
There was a problem hiding this comment.
New implementation able to handle resolving aggregate instance, storing it in repo and publishing events.
| /** | ||
| * licence Apache-2.0 | ||
| */ | ||
| final class AggregateResolver |
There was a problem hiding this comment.
This class resolve aggregates that are needed to be saved. No need for RESULT_AGGREGATE header anymore, as it will cover different scenarios to find out what is to be saved based on incoming message.
|
Will this somehow affect current implementations? When, for example, built-in repository with doctrine entity manager are used. We also use repository interface additionally to in-built event sourcing repository. For, example: interface CardRepositoryInterface
{
#[Repository]
public function getById(Uuid $id): Card; // event sourcing aggregate
}Will this still work? |
|
@dgafka after update to latest version this code stopped working (used it for testing the issue with outbox and amqp): #[CommandHandler(self::PREPARE_TICKET_TICKET)]
public static function prepare(PrepareTicket $command): array
{
return [new TicketWasPrepared($command->ticketId ?: Uuid::uuid4()->toString(), $command->ticketType, $command->description)];
}
#[CommandHandler(self::CANCEL_TICKET)]
public function cancel(): array
{
if ($this->isCancelled) {
return [];
}
return [new TicketWasCancelled($this->ticketId)];
}
#[EventSourcingHandler]
public function applyTicketWasPrepared(TicketWasPrepared $event): void
{
$this->ticketId = $event->ticketId;
$this->isCancelled = false;
$this->isAssigned = false;
}
#[Asynchronous('backoffice_db_amqp')] // combined channel
#[EventHandler(endpointId: 'ticket.wasPrepared')]
public function cancelAfterPrepare(TicketWasPrepared $event, #[Reference] CommandBus $commandBus): void
{
$commandBus->sendWithRouting(Ticket::CANCEL_TICKET, metadata: ['aggregate.id' => $event->ticketId]);
}In amqp consumer get exception: |
it still works with this code: #[Asynchronous('backoffice_outbox')]
#[EventHandler(endpointId: 'ticket.wasPrepared')]
public function cancelAfterPrepare(TicketWasPrepared $event): array
{
return $this->cancel();
}But it seems to me dangerous if something that previously worked stops working. |
Why is this change proposed?
Description of Changes
Pull Request Contribution Terms