Command to export data ?

DDD wise a request to export data is a command.

In Axon Commands are related to Aggregates, Is this always the case?

If I want to Export a data (Projection data)
Would you suggest to use commandGateway in the following way? or Am I sidetracking my logic somewhere?

-----my code is something like this

@PostMapping("/export")
public void doExport(){
commandGateway.send(new ExportProjectjonToFtpCommand (…))
}

Jobservice{

@CommandHandler
public handle(ExportProjectjonToFtpCommand command) {
blablabla.doAsync(ExportJob())
}

}

ExportJob{
public execute(){
data = queryGateway.query(Projection)

writeToFtp(data)
}
}

------any thoughts are welcome

Hi Sven,

I do not see anything wrong with that. You get to use Axon Server routing/broker mechanism for free. Your handler (job) component is decoupled from the REST adapter and you could deploy it independently (as a separate app) in the future if you like.

This post is explaining a similar case, with more details on how you can use @RoutingKey (together with the external command handlers) to gain more control: https://groups.google.com/forum/#!topic/axonframework/UGe0mjUMcrA

Best,
Ivan