szjani / predaddy

DDD/CQRS/EventSourcing framework with annotation driven message bus
MIT License
169 stars 6 forks source link

Are commands wrapped in a transaction? #5

Closed redthor closed 8 years ago

redthor commented 8 years ago

Hi @szjani

Just a question.

Here: https://github.com/szjani/predaddy/blob/3.0/src/predaddy/commandhandling/CommandBus.php#L31 it says that commands are 'typically' wrapped in a unique transaction. However the default implementation does not include the transaction wrapper does it?

The other rules:

the type of the message must be exactly the same as the parameter in the handler method

and

only one command handler can process a particular command, otherwise a runtime exception will be thrown.

look like they're enforced in the code. But not the transaction rule.

Thanks

szjani commented 8 years ago

Hi @redthor

Yes, you're right. Transaction handling is not enforced in the code. If you use https://github.com/szjani/predaddy/blob/3.0/src/predaddy/util/TransactionalBusesBuilder.php then you have to provide a TransactionManager. This is the recommended way to create a properly initialized command/event bus pair, however it is not a must. Even if you do not need transaction handling, you can pass a NOPTransactionManager instance to the builder.

redthor commented 8 years ago

great, thanks!