Make TransactionalApplicationListenerAdapter support fallbackExecution #34674
Labels
in: data
Issues in data modules (jdbc, orm, oxm, tx)
status: waiting-for-feedback
We need additional information before we can continue
status: waiting-for-triage
An issue we've not yet triaged or decided on
I have the following use case.
I have a bean that should act as a multi node event router.
The bean must listen for a particular event interface and broadcast a received event to the other nodes. If a transaction is running, event should be broadcast after commit. If there is no transaction, the event should be immediatly broadcast.
The event interface looks like this:
The router looks like this:
The obvious issue with this code is that the routers (plural because 1 router/node) may enter in an infinite broadcast loop. The easiest solution that comes to mind is to make the router check the event source and ignore the event if the source is itself. But since I am listening for a raw event, I don't have access to
ApplicationEvent
informations.I know that under the cover, Spring use
PayloadApplicationEvent
for raw events. So I try to implement the infinite loop guard like this:But when I do this, I loose
TransactionalApplicationListenerMethodAdapter#fallbackExecution
feature.Could we add this feature to
TransactionalApplicationListenerAdapter
and pass its activation as an argument toTransactionalApplicationListener#forPayload
?The text was updated successfully, but these errors were encountered: