Business logic inside event source method axon

I’m new to Axon and it is amazing framework.

I use Spring boot for my project with Axon.

Am allowed to add business login inside event source method (@ @EventSourcingHandler annotated method)? I don’t mean validation but some calculation ? or just mutate the aggregate?

Can I also dispatch an event from event source method?

Hi and welcome!

Yes, you should add business logic inside your event sourcing handler method if you need to compute a state change of your aggregate so that it is up-to-date for your next command handler method business logic (where you put your validations and stuff).

Hope this quick answer helps.

David

Thanx for answering me. Can I also raise a new event from within event source handler?

Could you please explain a little bit why you want to “raise” an event within an event sourcing handler? And by “raise” do you mean to apply or publish an event?

Say I have calculation inside an event sourcing function that update the aggregate state. Also the state require other event to be published for other aggregate. The kind of event is not similar to the original event