prooph / event-store-bus-bridge Goto Github PK
View Code? Open in Web Editor NEWMarry CQRS with Event Sourcing
Home Page: http://getprooph.org
License: BSD 3-Clause "New" or "Revised" License
Marry CQRS with Event Sourcing
Home Page: http://getprooph.org
License: BSD 3-Clause "New" or "Revised" License
Since we have removed the CausationMetadataEnricherFactory, all applications which uses this factory would be broken on composer update.
@prolic In reference to the (what i thought is the culprit) : prooph/pdo-event-store#84
I found out the cause is the transaction manager. With the transaction manager disabled, everything works as expected. With the transaction manager, I assume the transaction fails because the relation does not exist (see csv log)
https://gist.github.com/lunetics/70af26fe24bb819a54c6aa5c6d47be0d
When using the regular ActionEventEmitterStore
(e.g. via MySqlEventStore
) any error or exception triggered while recording the event (StreamNotFound
, ConcurrentyException
, RuntimeException
) still causes the respective event to be published.
This seems to be because these exceptions are caught, captured and respective flags set on the event to indicate this error. The EventPublisher
in turn doesn't check for these flags but always publishes them.
This only seems to be an issue for the ActionEventEmitterEventStore
as it dispatches the events right away without rollback.
The CausationMetadataEnricherFactory
is only invoked when the event store is created. Often this is only the case when some command handler requires access to it. Until this is the case, all dispatched commands are not set in the CausationMetadataEnricher
, making the first batch of events not having and _causation_id
.
Minimal example:
class CreateInternalDirectoryHandler
{
/** @var AggregateRepository */
private $repository;
public function __construct(AggregateRepository $repository)
{
$this->repository = $repository;
}
public function handle(CreateInternalDirectory $command)
{
$directory = InternalDirectory::create($command->id(), $command->name(), $command->description());
$this->repository->saveAggregateRoot($directory);
}
}
// main.php
$commandBus = $serviceManager->get('command_bus_incoming');
$commandBus->dispatch(CreateInternalDirectory::withData(/** .... */));
This will cause the command bus to be created before the event store (which is implicitly created while creating the command handler).
the chain of action is something like this:
create command bus -> dispatch command -> create handler -> create event store -> create enricher plugin -> attach to command bus
and use after_success instead of after_script for it
The causation enricher adds the metadata with the key _causation_id
:
When using eventstore.org (for example), this needs to be $causationId
. We could make this configurable, by injecting the names in the constructor. Alternatively we could introduce something like a Generator
with a default and eventstore.org implementation.
If an exception is thrown after event store commit (for example in a projection) then the TransactionManager tries to rollback the transaction again. So the event store throws another exception and the original one is lost.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.