-
Notifications
You must be signed in to change notification settings - Fork 157
Reactive Spring Modulith #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I would have to investigate how the Spring event publication would actually interact with reactive infrastructure. Unless there's a technical need to really implement the event publication repository in a reactive way, I think it should just be fine to persist event publications in an imperative way. |
Hmm, actually making reactive and non reactive JDBC working together in the same project is not straightforward. So having a Reactive implementation would be a great addition 👍 |
Interested in this as well. Regarding Spring Event Publication, even though it is not fully integrated in the reactive stack (see this Open issue), at least some support for non-blocking listeners exists (see this completed issue). As detailed in the second issue, declaring listeners like this works: @EventListener
public Mono<Void> handleEvent(Object event) {
...
} So I think it should be feasible to plug this with a reactive repository. |
Making it work is probably "feasible", but not obvious. In a simple implementation using the provided |
I am interested in this as well. This is currently blocking the adaption of Spring Modulith for us. @pcuriel As of Spring Framework 6.1, Spring Event Publication is fully integrated in the reactive stack. |
@odrotbohm I think persisting events in an imperative way may be sufficient but (and this is a big one) it is really hard to set up because there are many things to consider. Configuring a blocking and a reactive data access layer
Multiple Transaction Manager Beans
Event listeners can not be reactive as long as the event publication repository is blocking Now we have to consider the
The bottom-line is: Event listeners cannot be reactive, they have to be blocking due to the transaction management. As far as I understand this shouldn't be an issue as long as event listeners themselves are not doing any blocking I/O or similar CPU-intense tasks. Even then, declaring them as |
I have a working example of a reactive Spring application that uses Spring Modulith. Please keep in mind that the sample uses snapshot versions of Spring Framework 6.1 for the fix of spring-projects/spring-framework#21025. I had to jump through a lot of hoops to get this working:
I don't think it is feasible to do stuff like this in a production application. It is way too convoluted and complex for too minimal gain. I would recommend dropping reactive programming entirely or dropping Spring Modulith instead. At least until Spring Modulith has first-class support for reactive applications. @odrotbohm Sorry, the example is in Kotlin again 😇 |
I can only recommend to hold off experimenting with this for now. As you have already experienced, the current arrangement is not designed to work well on top of a reactive data store. This is primarily due to the way we integrate with Spring's event publication mechanism. It's currently implemented in a very straight-forward way, but at the same time, is exposed to limitations that affect the extent in which we can interact with the data store. I've been in touch with the Framework team and experts on reactive programming in our broader team, and I think there is a path forward to get this to work cleanly. That said, we're close to 1.0 RC / GA, which means that I'll only get to work on this post those releases. Big feature candidate for 1.1, though. |
I am visiting this discussion a year later, so I would like to ask what the current plans are for reactive support. |
We currently don't have any plans to move forward with this. |
Not sure for JPA, but it would be nice to have reactive JDBC and Mongo starters.
The text was updated successfully, but these errors were encountered: