Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bennidi/mbassador-spring
Use MBassador in Spring environment. Supports conditional event dispatch (e.g. after or before {commit|rollback})
https://github.com/bennidi/mbassador-spring
Last synced: about 1 month ago
JSON representation
Use MBassador in Spring environment. Supports conditional event dispatch (e.g. after or before {commit|rollback})
- Host: GitHub
- URL: https://github.com/bennidi/mbassador-spring
- Owner: bennidi
- Created: 2012-11-20T12:46:08.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2019-04-12T18:38:07.000Z (over 5 years ago)
- Last Synced: 2024-04-16T18:36:09.506Z (7 months ago)
- Language: Java
- Size: 37.1 KB
- Stars: 14
- Watchers: 4
- Forks: 10
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
mbassador-spring
================
[![Build Status](https://travis-ci.org/bennidi/mbassador-spring.svg?branch=master)](https://travis-ci.org/bennidi/mbassador-spring)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).Usage
```
// post the object only if a transaction exists and completes with rollback
bus.post(new Object()).after(Transaction.Completed().withRollBack());// post the object only if a transaction exists and commits succesfully
bus.post(new Object()).after(Transaction.Completed().successfully());// post the object only if a transaction exists but regardless of its outcome
bus.post(new Object()).after(Transaction.Completed().withAnyStatus());
bus.post(new Object()).after(Transaction.Completion()); // same same// post the object according to the specified transactinoal condition or immediately if none is present
bus.post(new Object()).after(Transaction.Completion().OrIfNoTransactionAvailable());
bus.post(new Object()).after(Transaction.Completed().withRollBack().OrIfNoTransactionAvailable());
bus.post(new Object()).after(Transaction.Completed().successfully().OrIfNoTransactionAvailable());
bus.post(new Object()).after(Transaction.Completed().withAnyStatus().OrIfNoTransactionAvailable());
bus.post(new Object()).after(Transaction.Completion().OrIfNoTransactionAvailable()); // same same// post the object before transaction completes (regardless of status)
bus.post(new Object()).before(Transaction.Completion());
// or immediately if none is present
bus.post(new 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
//bus.post(new Object()).before(Transaction.Completed().successfully());```