Let’s say I have a microservice which listens to topicOne and topicTwo. Then given certain conditions, I want to apply back pressure on topicOne (and buffer in coming events there) until I get a specific event from topicTwo.
@franz
Ok.
To block topicOne processing you need to throw an exception that will trigger Lagom subscriber to retry consuming of the same topic message.
In topicOne processing you need to check the status of topicTwo processing to determine if you need to block or to proceed.
You have two options for this check:
using entity
-topicTwo would trigger a command that would persist an event and flag entity state that topicOne can proceed
-topicOne would send a command that would check the state and if not flagged would reply with invalid command that would trigger an exception. If state is flagged then command reply would return a correct reply that would trigger next message consuming.
using read side
read side populated by topicTwo
read side queried by topicOne
Two optiona for topicTwo to populate read side:
a) topicTwo entity event processor
b) topicTwo populating read side when subscribing
Chosing a right option will mainly depend on topicOne and topicTwo business processing logic.