0

I am about to implement a JSR 352 BatchJob which is supposed to run on Wildfly in Domain Mode with two nodes on separate machines.

Will it be safe to use the same Jdbc JobRepository on each node via the JobOperator interface, or may there be conflicts?

I would like to ensure that a Job can only run once at a time and not parallell on the nodes.

Thomas
  • 620
  • 7
  • 19

1 Answers1

2

The short anser is yes, it is safe to use the same jdbc JobRepository.

The job execution is started by your application. So whether your job will be run only once at a time depends on how your application starts the job. If you application keeps starting this job while previous job execution is still running, then some request will be load-balanced to the other node and a new job execution will be started in that node.

cheng
  • 1,076
  • 6
  • 6
  • 1
    The scenario you described seems to be based on requests coming from outside the job nodes, as a REST invocation to start a job. What about scheduled jobs using EJB Timers that call JobOperator.start, how could we manage conflicts and prevent the same job from being triggered simultaneously on both nodes? Say I have a WAR with EJB Timers and jobs, could I safely deploy it in two similar JBoss/WildFly nodes? – Jose Tepedino Oct 06 '19 at 22:26
  • Yes, that is still true in your case. Whether in single-node or multi-node deployment, the shared jdbc job repository holds the true state of job executions. It is possible to start simultaneous job execution for the same job in single-node server, and cluster as well. If you want to avoid that, your application needs to check for the status of any existing job execution for a particular job name, and then decide if it's right to start a new job execution. – cheng Oct 07 '19 at 23:57