How to get jboss eap 7.1 to execute scheduled jobs defined in xml?
ncj Mar 3, 2019 9:26 AMI've managed to get a batchjob registered with the jboss eap 7.1 server. Thus I can start the job manually from the jboss eap 7.1 management web interface. I have kept it simple so far, only having the batchjob print out a simple text message I can view in the server log.
What I have not been able to get working is scheduled repetitive execution by the jberet framework which is my objective.
The server log outputs the following based on the xml file shown beneath.
Server log:
2019-03-03 13:42:09,400 INFO [stdout] (Batch Thread - 2) This is an xml specified property!
2019-03-03 13:42:09,403 INFO [org.jberet.schedule-executor] (Batch Thread - 2) JBERET072500: Created JobScheduler: org.jberet.schedule.ExecutorSchedulerImpl{executorService=java.util.concurrent.Executors$DelegatedScheduledExecutorService@43f71b4c}, based on resource: null
2019-03-03 13:42:09,421 INFO [org.jberet.schedule-executor] (Batch Thread - 2) JBERET072502: The following job execution is scheduled to run after execution 2 ends: schedule id 1, JobScheduleInfo{jobName='dbCleanUpBatchJob', jobExecutionId=0, jobParameters={}, initialDelay=1, afterDelay=0, interval=0, persistent=true, scheduleExpression='null'}
The xml file:
<?xml version=1.0 encoding="UTF-8"?> <job id="dbCleanUpBatchJob" 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" restartable="true"> <properties> <property name="interval" value="10"/> </properties> <listeners> <listener ref="org.jberet.schedule.SchedulingJobListeners"> <properties> <property name="initialDelay" value="1"/> <property name="afterDelay" value="1"/> <property name="interval" value="1"/> <property name="persistent" value="true"/> </properties> </listener> </listeners> <step id="dbCleanUpBatchJob.step1" allow-start-if-complete="true"> <properties> <property name="printThisValue" value="This is an xml specified property!"/> </properties> <listeners> <listener ref="org.jberet.schedule.SchedulingJobListeners"> <properties> <property name="initialDelay" value="1"/> <property name="afterDelay" value="1"/> <property name="interval" value="1"/> </properties> </listener> </listeners> <batchlet ref="[packagename].DbCleanUpBatchJob"/> </step> </job>
I would like to be able to define the schedule of the job in xml and just let the jberet subsystem handle the execution of the job.
However, if it's not possible I would also like to know how else to get the job scheduled.
I have looked at and read the jberet-user-guide as well as looked at a lot of the sample code on github. From there and the xsd I have come up with the above xml.
Do I need changes to the above xml or am I missing something else or maybe both?
The code which prints out the message from the xml file shown in the log from the server above:
package [package name] import javax.batch.api.AbstractBatchlet; import javax.batch.runtime.context.StepContext; import javax.inject.Inject; public class DbCleanUpBatchJob extends AbstractBatchlet { @Inject StepContext stepContext; @Override public String process() { String say = stepContext.getProperties().getProperty("printThisValue"); System.out.println(say); return "SUCCESS"; } }