Hi Jim,
The easiest way is to add the service as a parameter of your command handler method:
@CommandHandler
void handle(SomeCommand command, YourService service) { ... }
In case you're using Spring the service is injected automatically. If not you need to register the service with the parameter resolver passed to the aggregate repository.
However, to answer your second question, it's often not a great idea to call services (or perform other potentially slow operations) from within your AR. The reason is that your aggregate instance is locked while it processes a command. Any command that takes a long time to process therefore severely limits the throughput of commands for that instance. Also the throughput is then a function of 'random' external factors like the latency of the service in question.
Often it's better to call the service before sending the command and add the result of the service invocation to the command. Note however that other commands may reach the AR instance while the service is being invoked, though in most cases that shouldn't matter.
Regards,
Rene
> --
> You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
axonframewor...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.