Forcing a back pressure


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.

Is that possible, and how should I do that?


Hi @franz,

It sounds like the backpressure term in you context here is blocking processing of topicOne until certien conditions are fullfiled on topicTwo. Right?

That is right @aklikic. That is what I want :)

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:

  1. 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.
  2. 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.

Hope this helps.

Thanks. Option #1 is what I had in mind.

But to verify, all have to do is throw an exception within the the subscriber everytime my flag indicates to block messages? Did I get that right?


@franz yes