You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't get it. I recently saw a error popping out that told me this:
Spatie\EventSourcing\AggregateRoots\Exceptions\CouldNotPersistAggregate
Could not persist aggregate ItemAggregateRoot (uuid: 01971d73-5e2f-7386-97ae-bd2ee945da18) because it seems to be changed by another process after it was retrieved in the current process. Current in-memory version is 11
Ok. So I assume that my aggregate has been changed in the meantime. Okay. But I don't get it, because:
I am using a dedicated single-process queue for event sourcing
I am using the command bus
My reactor that triggers the event that leads to this problem, is queued
public function onCheckoutFailed(CheckoutFailed $event): void
{
$cart = Cart::findByAggregateUuid($event->aggregateRootUuid());
app(RestoreStock::class)(cart: $cart);
}
That action class does this:
final readonly class RestoreStock extends EventSourcedAction
{
public function __invoke(Cart $cart): void
{
$this->bus->dispatch(
new RestoreStockCommand(
aggregateUuid: $cart->aggregate_uuid
)
);
}
}
So I do not get how I'd have to refresh the aggregate root. How would I do that? And why is it possible that two processes are messing around with that aggregate at the same time?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I don't get it. I recently saw a error popping out that told me this:
Ok. So I assume that my aggregate has been changed in the meantime. Okay. But I don't get it, because:
That action class does this:
So I do not get how I'd have to refresh the aggregate root. How would I do that? And why is it possible that two processes are messing around with that aggregate at the same time?
I'd really love to hear your opinions.
Beta Was this translation helpful? Give feedback.
All reactions