Axon Aggregate - Calling External HTTP Clients from @Aggregate @CommandHandler

This is a question about what is suitable in a particular situation. I have heard that you may want to avoid long running calls in an @Aggregate @CommandHandler because it will lock the Aggregate for longer. I wanted to understand the specific disadvantages of locking the aggregate.

My Scenario:
We are handling payments and expect a sequence of commands -

  1. start session

  2. retrieve payment result after payment has been made in the browser

  3. receive notification about a payment result if it was still pending when retrieving the result

Now this is pretty much sequential for a specific aggregate instance, and I don’t think locking a specific aggregate instance would be a big problem here, am I missing something? Do you foresee any problems with having the calls to the payment provider inside the @CommandHandler?

If is seems ok do this this, then this feedback would be useful too - thanks!

Hi Stephen,

it’s technically ok to do so, but keep in mind that any commands to that aggregate will be blocked until the aggregate completes its previous command. Doing external activity may extend the time an Aggregate is doing processing.

Conceptually, it’s important to consider whether the external call is a result of something that has happened, meaning it should be done in an event handler, or that it is conceptually part of the processing of the command.
Those are some considerations to keep in mind. If it works for you, it works :wink: