0

I'm trying to start a batch job, which isn't known at deployment time. (Admin users can define their own jobs via rest-api) I'm calling:

JobOperator jobOperator = BatchRuntime.getJobOperator();

-- > Class org.wildfly.extension.batch.jberet.deployment.JobOperatorService - Which dosn't allow to start unknown jobs.

Javadoc says:

* Note that for each method the job name, or derived job name, must exist for the deployment. The allowed job names and
* job XML descriptor are determined at deployment time.  

How can i start jobs that are not determined at deployment?

Thanks in advance

joscht
  • 3
  • 2
  • If the job name isn't know at the time of deployment; then my next question is does the job even exist yet? – Rohlex32 Jul 16 '18 at 15:27
  • Have you tried Java-based JSL, i.e., programmatically create batch jobs and start them? Jobs created this way should not be subject to deployment time validation. – cheng Jul 16 '18 at 15:51
  • @cheng Programmatically created batch jobs can be started. Hint: With jobId = '*' JobOperatorService.validateJob can be tricked. Required if, for example, getJobExecution is called. – joscht Jul 17 '18 at 17:08
  • The validation does seem a bit too restrictive. We should investigate how to accommodate use cases like this. – cheng Jul 18 '18 at 00:00

1 Answers1

2

You can have some conventions in your batch job naming, so that it is kind of known at deployment time to bypass the deployment-time validation. For instance, you can package a placeholder job in your application:

<?xml version="1.0" encoding="UTF-8"?>

<job id="submitted-job" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/jobXML_1_0.xsd" version="1.0">

  <!-- this job is defined and submitted dynamically by the client  -->

</job>

At runtime, the admin can then dynamically fill in the job content.

cheng
  • 1,076
  • 6
  • 6