Bulk write/saves to DB using Axon framework


I am a newbie to Axon Framework and Spring framework. Using Axon framework how can bulk saves to database be performed? The requirement is to upload a csv file containing thousands of Student information and create Student records in the Postgres DB.
I am aware of Spring Batch with which one can schedule a “Job” which performs “Step”. A Step typically performs ETL i.e extract , transform and finally load (DB save)

Is Spring Batch the right approach for bulk saving to DB or is there any other approach?

Hi Amit,

When using Axon you will likely embrace the usage of DDD, CQRS and Event Sourcing.

CQRS will thus mean you are segregating your application into a Command Part and a Query Part.
When asking things like “bulk safe to a database”, you are more so thinking in one point of entry doing both, which is typically not what you’d use Axon for.

However with CQRS it’s requested of you to think in terms of actual operations you want to do.
Your CSV file likely requires the creation of a distinct Student entry per line (note: I am making assumptions on your domain, for which I am far from an expert).

Thus, you will likely have a “CreateStudentCommand” for each of those entries.
The process of ingesting the CSV file, transforming them to commands and dispatching those is something you will have to build yourself.

What happens after the command dispatching is again up to your specific domain.
(again) likely, they will be targeted towards an Aggregate first (the Command Model), which in turn publishes an event.
It’s only then with the event that you will be able to update projections, since we are following CQRS on the matter.

As you might be reading here I am making a lot of assumptions, with which I hope the general idea of using Axon becomes somewhat clearer.
Final suggestion: start off with a simple application where you can create a single student.

From there I would start looking at building bulks of those.

Hope this helps!