-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor aggregate module #424
Conversation
|
||
} | ||
|
||
public function process(Message $message): Message|null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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