Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Batch job in cluster environment

We have a cluster with 2 JBOSS nodes. We have a batch job which loads all users details from a active directory to a DB. This job is run everyday. It was run before in a non clustered environment and hence we designed it as a singleton. Now we have a clustered environment and I do not know what is best way to achieve the same result. I want batch job to be run only once a day. We use spring and hibernate and I looked at Spring batch. I could not get any concise answer to my question.

Can anybody please let me know if you had implemented batch in cluster environment? What would be the best solution in this scenario?

like image 523
Abhijith Prabhakar Avatar asked Jul 21 '11 05:07

Abhijith Prabhakar


People also ask

What is Java batch job?

A batch application is a Java™ Platform, Enterprise Edition (Java EE) application that conforms to one of the batch programming models. Batch work is expressed as jobs. Jobs are made up of steps. All steps in a job are processed sequentially.

What is batch execution in Kubernetes?

To create batch transactions, Kubernetes provides two workload resources: the Job object and the CronJob object. A Job object creates one or more Pods and attempts to retry the execution until a specified number of them terminate successfully. CronObjects, such as crontab, run on a cron schedule.

Is Spring Batch A Microservice?

Spring Batch is a minimalistic framework to run batch processing applications. Spring Cloud Task is a wrapper allowing you to run short-lived microservices using Spring Cloud along with Spring Boot. Spring Cloud Data Flow allows you to build composed tasks orchestrating Spring Batch jobs as Spring Cloud Tasks.

What is batch job why it is used?

In the simplest terms, a batch job is a scheduled program that is assigned to run on a computer without further user interaction. Batch jobs are often queued up during working hours, then executed during the evening or weekend when the computer is idle.


1 Answers

We implemented this by triggering and starting the jobs externally via MQ ( an http request to start the job would work as well). The scheduler puts a message on the queue and even though we have 'n' nodes listening to the queue, one node will receive the message and based on it's contents, start the job. You can do this with HTTP as well.

The real 'solution' to this is to schedule the batch job 'externally' and not via an internal cron trigger. The actual start mechanism is secondary to that.

like image 59
Trever Shick Avatar answered Nov 12 '22 01:11

Trever Shick