Asynchronous communication between modules via events leads to a cycle detected violation #1119
Unanswered
KarasDominik
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a simple web app with an order module responsible for handling orders in an online shop. I want to add payment handling functionality, and my initial idea was as follows:
The order module, after processing all the logic and saving the order to the database, publishes an OrderCreatedEvent.
The payment module receives the event and handles the payment logic. Once the payment for the order is received, it publishes a PaymentReceivedEvent.
The order module receives this event and updates the database to reflect that the order has been paid.
I wanted to use @ApplicationModuleListener to handle this, but this design violates Spring Modulith validation as it creates a cycle.
How can I handle this? Let's say I want to provide an endpoint that includes both order information and their payment status—do I need to create a third module to store this data?
Beta Was this translation helpful? Give feedback.
All reactions