Skip to content

SBrown52/mongodb-spring-batch-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MongoDB Spring Batch Examples

This repo contains some basic examples of using Spring Batch with MongoDB. Check each subdirectory for the various examples.

NB: Each directory contains a complete example. No code is shared between examples in order to make it simpler to understand and run.

Examples

MongoDB Usage

Obviously, You will need an instance of MongoDB running! By default this project connects to a local MongoDB instance on port 27111 (NB: non-standard, you may want to update this). Alternatively, you can create an MongoDB Atlas instance and connect to it.

Configuration

All configuration is in the application.yaml files. You can can edit the host, port add security etc for your MongoDB cluster here.

Atlas Setup

If you are using Atlas, you will need to set the following in application.yaml:

spring:
  data:
    mongodb:
      uri: mongodb+srv://user:pass@atlasurl.mongodb.net

You can get your Atlas URI from the Atlas console.

Why is there a relational database in here?

Spring Batch uses a relational database to store job metadata. This allows it to keep track of progress, and can be used to restart or rerun jobs in case of failure. Although you do not need to specify any logic for this to work (by default Spring will handle it all for you), we purposefully configure a H2 instance to store this data. You can then query the H2 instance and see what records it holds

Performance

This project, so far, is designed to show examples on how to use Spring Batch with MongoDB, it does not try to write the efficient or performant jobs. You will need to read the Spring Batch doc and make those changes on your own system.

Official Spring Guides

The following guides illustrate how to use some features concretely:

About

Examples of using MongoDB with Spring Batch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages