Use MBassador in Spring environment. Supports conditional event dispatch (e.g. after or before {commit|rollback})
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Build Status

CDI-like transactional events in Spring!

Use MBassador in Spring environment. Supports conditional message dispatch (e.g. after or before {commit|rollback}) based on Springs TransactionSynchronization.

This project is currently in beta but is planned to be continuously improved to create a stable release. The functionality to synchronize the message dispatch with spring managed transactions is implemented completely but still lacks a great deal of testing.

For the declaration of transactional conditions on the message listeners a solution is still to be found. Most likely, a specific class that wraps the message can be used (similar to EnvelopedMessage in standard mbassador).

Please download and test this mbassador extension for your use cases and provide me with feedback and test cases. I think that declarative transactional event listeners would be a great addition to the spring ecosystem (of which I am a great fan).


// post the object only if a transaction exists and completes with rollback Object()).after(Transaction.Completed().withRollBack());

// post the object only if a transaction exists and commits succesfully Object()).after(Transaction.Completed().successfully());

// post the object only if a transaction exists but regardless of its outcome Object()).after(Transaction.Completed().withAnyStatus()); Object()).after(Transaction.Completion()); // same same

// post the object according to the specified transactinoal condition or immediately if none is present Object()).after(Transaction.Completion().OrIfNoTransactionAvailable()); Object()).after(Transaction.Completed().withRollBack().OrIfNoTransactionAvailable()); Object()).after(Transaction.Completed().successfully().OrIfNoTransactionAvailable()); Object()).after(Transaction.Completed().withAnyStatus().OrIfNoTransactionAvailable()); Object()).after(Transaction.Completion().OrIfNoTransactionAvailable()); // same same

// post the object before transaction completes (regardless of status) Object()).before(Transaction.Completion());
// or immediately if none is present Object()).before(Transaction.Completion().OrIfNoTransactionAvailable());

// compile error: the outcome is only available after completion so its not possible to refer
// to any transaction specific outcome when scheduling a message to be published in "Before"-Phase
// Object()).before(Transaction.Completed().successfully());