Posts

Job Repository - Spring Batch Part 3

Image
Spring Batch's Job Repository does the work of Scheduling and Interacting with Jobs. It also manages failures and reruns. As we saw in the previous blog, a Job can have multiple steps - Job Repository handles it all. It does all of the management using a few tables in the database. Till now, we have been using the h2 in-memory database - which actually creates a new instance of the db everytime we restart the application. Lets use standalone h2 db, so we can take a look at the tables involved and the data it holds. Git repo link:  https://github.com/ricsr/spring-batch-demo/tree/exercise_03 Download H2 DB and open the console.  Edit your application.properties with the following as reference: spring.datasource.url = jdbc:h2:tcp://localhost/~/test spring.datasource.driverClassName = org.h2.Driver spring.datasource.username = sa spring.datasource.password = test spring.jpa.database-platform = org.hibernate.dialect.H2Dialect Start your application. Once the application runs succes...

Creating multiple SpringBatch Job - Spring Batch Part2

Let us consider, you own a corporate gift shop and its Christmas time!! You are accepting bulk orders and offer delivery. Lets see how to solve it using Spring Batch. Entire sample code is available at:   https://github.com/ricsr/spring-batch-demo/tree/exercise_02/src/main/java/com/ricsr/springbootdemo There are three steps involved in this process: Read an order  Package an order Ship the order for delivery Let us create these three steps: @Bean public Step readOrderStep () { return this . stepBuilderFactory .get( "readOrderStep" ).tasklet( new Tasklet() { @Override public RepeatStatus execute (StepContribution contribution , ChunkContext chunkContext) throws Exception { System. out .println( "Order Received" ) ; return RepeatStatus. FINISHED ; } }).build() ; } @Bean public Step packageStep () { return this . stepBuilderFactory .get( "packageStep" ).tasklet( new Tasklet() { @Override public RepeatSt...

Creating your SpringBatch Application - Part 1

Image
Lets look at creating a very simple Spring Batch Application using Spring Boot. You can download the entire example from:   https://github.com/ricsr/spring-batch-demo/tree/exercise_01 Step1: Lets create our project. Goto  https://start.spring.io/ , and select Spring Batch and H2 Database as dependencies. Click on generate. Note that I am using Gradle. You are free to use Maven for dependency management. Step2: Import the project into you IDE. I am using IntelliJ in my examples. Step3: Edit your main class. In my case its the  SpringbootdemoApplication.class package com.ricsr.springbootdemo ; import org.springframework.batch.core.Job ; import org.springframework.batch.core.Step ; import org.springframework.batch.core.StepContribution ; import org.springframework.batch.core.configuration.annotation. EnableBatchProcessing ; import org.springframework.batch.core.configuration.annotation.JobBuilderFactory ; import org.springframework.batch.core.configuration.annotation.StepBui...

Batch Processing with Spring Batch

Image
What is Batch Processing Runs as a process without human intervention Runs as a background process The input is fixed: Can be service calls, files from a location, db entries etc Scheduled at a particular time Examples of where Batch Processing can be useful: End of Day Balance Sheet Reporting Weekly reporting Monthly reporting Yearly reporting.. and so on Credit Card Statements Synchronizing between two systems (source and target) Jobs should be scheduled according to Business Requirements. Why use Spring Batch with Java? Spring Batch is the de facto standard for batch processing on the JVM. Its implementation of common batch patterns, such as chunk-based processing and partitioning, lets you create high-performing, scalable batch applications that are resilient enough for your most mission-critical processes. Spring Boot provides an additional level of production-grade features to let you speed up the development of your batch processes. Batch processing fits ...

Agile

We have been using Agile in our project for months now. We have a Scrum Master, a Scrum board, a daily standup. We even have a retrospective and a backlog grooming. Agile is meant to empower all of us to do great at work, give us a sense of accomplishment. But Agile made life miserable. Scrum Calls was becoming a mean of questioning everyone of what has been done, what has not been done. The Retrospective was more of blame game, blaming each other OR other teams our own incompetency of completing the tasks. But why is Agile so great? Why have projects following Agile become successful? Why knowing Agile puts you a step ahead of others? Probably because Agile is not what we all think it is. Agile is much different and much more helpful if used correctly. Becoming Agile is a never ending journey that everyone needs to take. Be it a Product Owner, A Scrum Master or a Developer. Product Owner - He represent the Users. He/She is responsible to bring the groomed stories for the ...

Cloud Computing

Image
Click Here: Getting Started with AWS What is cloud? Cloud computing is the practice of using a network of remote servers hosted on the Internet to store, manage and process data rather than manage your own servers Why cloud? Cost effectiveness : There is a peak time for every server (When there are maximum people accessing the website). Apart from this peak time, not all your servers will be used. In such a case it is better to use shared servers, where you pay as you use.  Improved security and no maintenance: You don't have to think about the security and maintenance of the servers. This reduces your overhead of having a team to maintain the infrastructure and worrying about the security Scalability : Since there are multiple servers which can help you run your application, you need not worry about the scalability of the infrastructure. Just have a proper scalable code and the service provider will take care of the infrastructure. Types of Cloud Computing models: Ia...

Angular - Good to know facts for developers

Setup angular app Setup  here No restarting your application while development. npm start This command runs the Typescript compiler in "watch mode" - ie any changes you make to your code will automatically get reflected in the browser. Your code will get launched and when changes are made, the browser will refresh and display your changes. Manage dependencies using npm Simply manage all your angular and angular app dependencies using npm - node package manager. node.js and npm are essentials for angular development, get them if you dont already have them. Separate devdependencies and dependencies With Angular you can have separate development dependencies and separate deployment dependencies. You no longer need to worry about packaging you dev dependencies. angular-in-memory-web-api It is an angular-supported library. You don't need an actual server or real HTTP calls. You can simulate the behavior using this library. bootstrap A pop...