Posts

Showing posts with the label Spring Boot Batch Job

How to create dynamic steps in Spring Batch

We can create steps dynamically and return the job reference. Here is an example - @Bean public Job job() { Step[] stepsArray = // create your steps array or pass it as a parameter SimpleJobBuilder jobBuilder = jobBuilderFactory.get("mainCalculationJob") .incrementer(new RunIdIncrementer()) .start(truncTableTaskletStep()); for (Step step : stepsArray) { jobBuilder.next(step); } return jobBuilder.build(); }

Sending Bulk SMS using Sprint Boot Batch

You must use Spring Boot Batch Jobs to send the bulk SMS's.  It's very flexible to schedule these jobs using Cron expression, so you can send the SMS as per the requirement. e.g. daily, weekly or at a particular time.  We need to integrate our job with the SMS provider like - msg91 Following is the Job configuration - This class has reader which will read the data for SMS content and job defination @Configuration @EnableBatchProcessing public class SmsBatchConfiguration { @Autowired @Qualifier("smsContentReader") public ItemReader > itemReader; @Autowired @Qualifier("nenewalNotificationSMSProcessor") RenewalNotificationSMSProcessor renewalNotificationSMSProcessor; @Autowired @Qualifier("smsSender") SmsSender SmsSender; @Autowired public JobBuilderFactory jobBuilderFactory; @Autowired public StepBuilderFactory stepBuilderFactory; @Value("${renewal.batch.notifications.email}") private String email...

Spring Boot Batch - Parallel Processing (Running Multiple Jobs Concurrently)

Image
If you are new to Spring batch please check the earlier post about S pring batch introduction In this post we will see Spring boot batch example, Spring boot batch parallel processing example Spring boot batch parallel processing allows multiple batch jobs to run in parallel to minimize the total elapsed batch processing time. This is not a problem as long as the jobs are not sharing the same files, db-tables, or index spaces. If they do, this service should be implemented using partitioned data. We will create the application having the following 2 jobs -  1st Job: Reads the P roduct information from the database and after processing will give the rating to the project. 2nd Job: Reads the Invoice the information the database and update back to the database.  We are not focusing on the business logic here but the processing of data using multiple jobs. Technical Details -  Java 8 Spring Boot 2.x Spring Batch 4.x MySql 5...