Sunday, December 10, 2017

Spring batch - running multiple jobs in parallel using PCF Scheduler

Step1: Download spring-boot-batch-multi-jobs project

https://github.com/making/spring-boot-batch-multi-jobs

Add following details to pom.xml:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
    <groupId>org.hsqldb</groupId>
    <artifactId>hsqldb</artifactId>
    <scope>runtime</scope>
</dependency>

$ ./mvnw clean package -DskipTests=true
Run all jobs

$ java -jar target/spring-boot-batch-multi-jobs-0.0.1.RELEASE.jar
Run only specified jobs

Only job1

$ java -jar target/spring-boot-batch-multi-jobs-0.0.1.RELEASE.jar --spring.batch.job.names=job1
Only job2

$ java -jar target/spring-boot-batch-multi-jobs-0.0.1.RELEASE.jar --spring.batch.job.names=job2
job1 and job2

$ java -jar target/spring-boot-batch-multi-jobs-0.0.1.RELEASE.jar --spring.batch.job.names=job1,job2


References:

https://docs.spring.io/spring-batch/4.0.x/reference/html/domain.html#domainLanguageOfBatch
https://stackoverflow.com/questions/45718888/spring-batch-running-multiple-jobs-in-parallel
https://docs.spring.io/spring-javaconfig/docs/1.0.0.M4/reference/html/ch02s02.html
https://docs.spring.io/autorepo/docs/spring/4.1.4.RELEASE/javadoc-api/org/springframework/core/task/SimpleAsyncTaskExecutor.html
https://docs.spring.io/spring-boot/docs/current/reference/html/howto-batch-applications.html



Saturday, December 9, 2017

a) Installing Mysql on Windows

1.Download Mysql zip(mysql-5.6.38-winx64) file

2. Extract the mysql folder

3. Execute the following commands
Step1: Run the server using the below command(C:\Softwares\mysql-5.6.38-winx64\bin)
Run mysqld --console

Step2: Reset the below command in new command prompt:(C:\Softwares\mysql-5.6.38-winx64\bin)

mysqladmin -u root password mysql

Step3: Connect mysql using the follwing command in new command prompt:(C:\Softwares\mysql-5.6.38-winx64\bin)

mysql -u root -p mysql


Step 4: Create database

create database db;

Step 5: Using the newly created db:

use db;


Step 6 : Shutdown of the Mysql
Run the server using the below command(C:\Softwares\mysql-5.6.38-winx64\bin)

Run mysqladmin -u root shutdown




b) Executing the mysql through mysql workbench:

1.Download Workbench from the below link:

https://dev.mysql.com/downloads/workbench/

2. Extract the file
3. Run the mysql work bench