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


Monday, July 31, 2017

Setting Apache Maven In Eclipse

Download Apache Maven from site(https://maven.apache.org/download.cgi)
















Unzip to folder some folder C:/tools


Open the C:\tools\apache-maven-3.5.0\conf\settings.xml for specifying local repository path
to  <localRepository>C:/mvnrepo/.m2/repository</localRepository>

Setup Maven environment variables:

MAVEN_HOME=C:\tools\apache-maven-3.5.0
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_79
Path=%Path%;C:\tools\apache-maven-3.5.0\bin;C:\Program Files\Java\jdk1.7.0_79\bin;

Check Maven version to see if environment variables is setup













Open your Eclipse
Go to the Windows --> Preferences -- > Maven
(Note: Install Maven plugin if its not visible in Eclipse)



Add Remote catalog in Maven Archetypes

(http://repo.maven.apache.org/maven2/archetype-catalog.xml)


















Add External Maven Installation path to C:\tools\apache-maven-3.5.0


Update User Settings to External Maven Settings file

Click on Update Settings button and Apply and then OK button

Create a New Maven Web Project:


After setting the archetype and group, it will automatically download the dependencies to local repository folder



You can also add dependency in pom.xml and see the new jars coming into the above local repository folder.

Saturday, July 29, 2017

Creating Web Service in Java Using Eclipse

Open Eclipse and create new Dynamic Web Project









































Setup the Target runtime to Tomcat 7 


































After updating the Tomcat 7 server










































Click Finish and after that create a new class HelloWorldService







































Add new method sayHello(String name)
















Right click on project and create a new WebService and add the above class at the creation of new webservice






























and select the Test service and Test Client and check the Publish the web Service checkbox










































Click Next









































Click Next and Click on Start Server button








































Once the server will start..Click on Next and Launch WebService Explorer








































It will open the  HelloWorld WebService sayHello web method. You can test the same.






























































Click Next Test WebService









































Click Next





































Click Next




































Click Finish. You will see the 

http://localhost:7534/HelloWorldWebServiceClient/sampleHelloWorldServiceProxy/TestClient.jsp