Comments (9)
@graemerocher We can do the work on this and issue a PR but was looking for some consensus on this.
from grails-async.
We could close this feature request if we were the only ones interested in it. For synchronous events that need to be in a transaction, we are leaning on Spring's built-in event support.
We inject ApplicationEventPublisher and call publisher.publishEvent(event) as well as using this events eventBus.notify(event.routingKey, event) so Asynchronous listers can be used as well. 2 calls to 2 different event buses but it works and its fast. Can use the old way of implementing their ApplicationListener or use the newer @eventlistener annotation to on the listening end.
Spring has refactored it to use generics and it performs really well.
from grails-async.
You can already subscribe GORM events synchronously by using @Listener
instead of a @Subscriber
from grails-async.
yes, but only if it's gorm event and it operate under a completely different mechanism with GormEventDispatcher. Also requires any events that you might want synchronous to be an AbstractPersitentEvent. If we can just have a buildNotificationCallableSync and a subscribeSync then it would be easy to extend and have both simliar to what is done in the SynchronousEventBus setup for testing. There are a ton of use cases for this but the biggest one would be events that are transactional and don't use GORM, specifically in lighter weight microservices.
from grails-async.
We are using a forked version of Platform plugin and were hoping to replace it with this or at least be able to extend this, the only main thing missing from the base EventBus is a mechanism for synchronous events. The way its deisgned its also more or less locked down so we can't even add another , less than ideal solution, SynchronousEventBus as it will blow an IllegalStateException
from grails-async.
Sounds good. Contributions welcome
from grails-async.
We are also interested in a way to subscribe to events synchronously and have them execute with the same transaction as the publisher. I was considering implementing a custom event bus that allows me to look at the subscription to see if it should be synchronous before returning the callable wrapper. I haven't really gotten to implementing it so there could be other problems with this approach.
from grails-async.
After implementing the same solution as @basejump I started wondering why I even needed the Grails EventBus
part of it at all. It seems like the spring event handling, especially with the newer annotation support, can handle most of the sync and async needs just fine.
By adding @Async
to the method, I can handle the asynchronous requirement. Also, the @EventListener(condition = ...)
is nicer for specifying dynamic conditions such as regex eventId matching or just other special matching conditions.
The downside is that I don't see any call back support for handling 'replies' on the spring side, so no sendAndWait
equivalent.
Are there other reasons that I might prefer using the Grails event plugin vs. the built-in spring support that I'm not considering?
Just thinking out loud really, but it seems like they have mostly overlapping functionality so I'm wondering why both.
from grails-async.
Was there any development to this issue? I'm in a similar position, attempting to replicate synchronous events, if nothing else I'd like to use the sendAndReceive functionality however can't find any documentation explaining how to do so.
from grails-async.
Related Issues (20)
- Migrate to Develocity build cache connector
- java.lang.NoClassDefFoundError: org/grails/encoder/CodecFactory HOT 1
- Evaluate if Sitemesh dependency is now necessary
- Add implementation to addErrorHandler
- Fix failing tests in Travis HOT 1
- Fix pubsub-demo tests dependencies failing
- Execute groovydoc in travis HOT 1
- Update travis credentials HOT 1
- WebPromise broken when Interceptor present (Grails 3.3.9)
- Does it support servlet 3.1?
- Subclasses of Event cannot be used in subscriber method signature
- Documentation: no links to earlier versions HOT 1
- Missing Source Jars For grails-events HOT 1
- Events fired from transaction callback are not received HOT 2
- Upgrade to Groovy 3.0.7 and Grails 5.0.x, and lasted version of rxjava1, rxjava2 HOT 5
- SendAndReceive does not trigger when subscriber is a method
- Async Task Out of Memory Hangs Application without OOME
- Version in grails-plugin.xml in published artifact is wrong HOT 1
- Task 'docs' not found in root project 'grails-async' and its subprojects.
- Dependency Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grails-async.