Posts

Showing posts from April, 2021

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...