Using cosmos db for Spring batch job repository

Viewed 586

Is it possible to use CosmosDB as a job repository for Spring Batch? If that is not possible, can we go with an in-memory DB to handle our Spring batch jobs? The job itself is triggered on message arrival in a remote queue. We use a variation of the process indicator in our current Spring batch job, to keep track of "chunks" which are being processed. Our attributes for saveStep are also disabled . The reader always uses a DB query to avoid picking up the same chunks and prevent duplicate processing. We don't commit the message on the queue , till all records for that job are processed. So if the node dies and comes back up in the middle of processing , the same message would be redelivered , which takes of job restarts. Given all this, we have a choice of either coming up with a way to implement a cosmos job repository or simply use in-memory and plug in an "afterJob" listener to clean up the in-memory job data to ensure that java mem is not used in Prod. Any recommendations?

1 Answers

Wanted to provide information that Azure Cosmos DB just release v3 of the Spring Data connector for the SQL API:

The Spring on Azure team, in partnership with the Azure Cosmos DB team, are proud to have just made the Spring Data Azure Cosmos DB v3 generally available. This is the latest version of Azure Cosmos DB’s SQL API Spring Data connector.

Also, Spring.io has an example microservices solution (Spring Cloud Data Flow) based on batch that could be used as an example for your solution.

Additional Information:

  • Spring Data Azure Cosmos DB v3 for Core (SQL) API: Release notes and resources (link)
  • A well written 3rd party blog that is super helpful: Introduction to Spring Data Azure Cosmos DB (link)
Related