Git Product home page Git Product logo

spring-batch-mysql-to-mongdb's Introduction

Spring Batch Example - MySQL to MongoDB

An example project using Spring Boot and Spring Batch.

This project shows how to configure a Spring Batch job to read data from MySQL database and copies to a NoSQL database - MongoDB with the help of scheduler batch processing and spring boot.

Requirements

  • Java 8
  • You must set MySQL, and MongoDB databases installed on your system.
  • Maven 3.5.* or higher
  • The Lombok library is being used as a resource to help with the creation of classes, check if your IDE has support/plugin to use Lombok. More information at https://projectlombok.org.
  • Import MySQL schema file \src\main\resources\world.sql into MySQL database.

Getting Started

Reference documentation

For further reference, please consider the following sections:

Guides

The guides below illustrate how to correctly use some spring batch features:

Environment variables

The application.properties file in the src\main\resources folder contains the environment variables that will be used by the application. If no environment variable is informed, the deafult values ​​will be used. Description of the variables:

  • spring.datasource.url : Connection string to the Spring Batch source repository database which is MySQL server address with the database name.

  • spring.datasource.username : User connecting to the Spring Batch source repository database.

  • spring.datasource.password : Password for connecting to the Spring Batch source repository database.

  • spring.data.mongodb.host : Server address of the Spring batch destination repository database which is a MongoDB.

  • spring.data.mongodb.port : Server port no of the Spring batch destination repository MongoDB.

  • spring.data.mongodb.database : Mongo Database name Spring batch destination repository.

  • spring.data.mongodb.username : Username for connecting to the Spring Batch destination repository database.

  • spring.data.mongodb.password : Password for connecting to the Spring Batch destination repository database.

  • scheduler.cron : = The cron expression value used to perform Spring Batch jobs from time to time or periodically on a fixed time. The default value is 0 0 */2 * * ? (At second:00, at the minute:00, every 2 hours starting at 00 am, of every day).

  • scheduler.timezone : The cron expression is evaluated based on this time zone. The default value is UTC.

How to run

This application will copy values from one repository to another repository. Here source repository is a MySQL database and the destination repository is MongoDB. The primary aim is that Move all the values from the MySQL database which is Cities in the world to the Mongo database. And this migration happens with the use of various classes provided by Spring Batch.

  • You can run start the application with the help of maven and apache tomcat as any spring boot runs.
  • You can invoke the batch process by calling the controller /invoke. The default address of the API will be: localhost:5800/invoke.
  • You can also configure the batch process as a scheduled job. You can configure the time in environment variables as mentioned above.

Issue

This repository isn't maintained actively, so if you face any issue please raise an issue.

Liked the work?

Give the repository a star :-)

spring-batch-mysql-to-mongdb's People

Contributors

jasimismail avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.