Skip to content

Circular dependencies working with events and agregate associations #493

Answered by JosRoseboom
matses asked this question in Q&A
Discussion options

You must be logged in to vote

Hi matses,

Don't know if you are specifically aiming for an answer from @odrotbohm , but I can share my thoughts. The way I did that is by letting the decision to make a service call or listen to an event depend on the direction of the dependency.

In your case, Order depends on Catalog. Instead of publishing an event from Order, OrderService could call ProductService to update the status.

Conceptually, the catalog is only aware of the possibility of changing a state of a product. There's no need to know that this is caused by an order being placed.

If something happens to a product that the order should be aware of (say the price changes and this is relevant for pending orders), the catal…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@odrotbohm
Comment options

@matses
Comment options

Answer selected by odrotbohm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants