This module supports integration between JBeret and Apache Camel, by providing a Camel JBeret component, and reusable batch artifacts for interacting with Apache Camel.
Camel JBeret component producer supports the following types of operations and their URL format:
-
jberet:jobslists job names. The response type isjava.util.Set<String>. -
jberet:jobs/job1starts the job job1. any job parameters should be passed as message body asjava.util.Properties. The response type islong(job execution id). -
jberet:jobs/job1/startstarts the jobjob1, same as above. any job parameters should be passed as message body asjava.util.Properties. The response type islong(job execution id). -
jberet:jobinstances?jobName=job1&start=0&count=10lists job instances,jobNamequery param is required,startandcountquery params are both optional, and defaults to0and10, respectively. The response type isjava.util.List<JobInstance>. -
jberet:jobinstances/count?jobName=job1counts job instances of the jobjob1.jobNamequery param is required. The response type isint. -
jberet:jobexecutions/running?jobName=job1lists all running job executions of the jobjob1.jobNamequery param is usually specified, but if omitted, it defaults to*and lists running job executions of all jobs currently known to the batch runtime. The response type isjava.util.List<Long>(job execution ids). -
jberet:jobexecutions/123456gets the job execution with id123456. The response type isJobExecution. -
jberet:jobexecutions/123456/stopstops the job execution with id123456. No response is generated. -
jberet:jobexecutions/123456/restartrestarts the job execution with id123456. any job parameters should be passed as message body asjava.util.Properties. The response type islong(job execution id). -
jberet:jobexecutions/123456/abandonabandons the job execution with id123456. No response is generated.
Implementation of javax.batch.api.chunk.ItemReader that reads batch data
from Apache Camel endpoint. The source Camel endpoint is configured through
batch property endpoint in job XML. For each read operation, this reader will wait
up to the configured timeout milliseconds for data. Users may also configure
beanType batch property to specify the expected Java type of the data.
An example job.xml using camelItemReader:
<job id="camelReaderTest" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
<step id="camelReaderTest.step1">
<chunk>
<reader ref="camelItemReader">
<properties>
<property name="beanType" value="org.jberet.samples.wildfly.common.Movie"/>
<property name="endpoint" value="#{jobParameters['endpoint']}"/>
<property name="timeout" value="#{jobParameters['timeout']}"/>
</properties>
</reader>Implementation of javax.batch.api.chunk.ItemProcessor that processes
batch data using Apache Camel component. The target Camel endpoint is configured
through batch property endpoint in job XML. For example,
<job id="camelReaderTest" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
<step id="camelReaderTest.step1">
<chunk>
... ...
<processor ref="camelItemProcessor">
<properties>
<property name="endpoint" value="#{jobParameters['endpoint']}"/>
</properties>
</processor>
... ...Implementation of javax.batch.api.chunk.ItemWriter that writes batch data
to Apache Camel endpoint. The target Camel endpoint is configured through
batch property endpoint in job XML. For example,
<job id="camelWriterTest" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
<step id="camelWriterTest.step1">
<chunk>
... ...
<writer ref="camelItemWriter">
<properties>
<property name="endpoint" value="#{jobParameters['endpoint']}"/>
</properties>
</writer>
</chunk>
</step>
</job>An implementation of javax.batch.api.listener.JobListener that sends
job execution events to a Camel endpoint. Two types of events are sent:
- beforeJob: sent before a job execution
- afterJob: sent after a job execution
The body of the message sent is the current JobExecution. Each message
also contains a header to indicate the event type: its key is eventType,
and value is either beforeJob or afterJob.
The target Camel endpoint is configured through batch property endpoint
in job XML. For example,
<job id="camelJobListenerTest" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
<listeners>
<listener ref="camelJobListener">
<properties>
<property name="endpoint" value="#{jobParameters['endpoint']}"/>
</properties>
</listener>
</listeners>An implementation of javax.batch.api.listener.StepListener that sends
step execution events to a Camel endpoint. Two types of events are sent:
- beforeStep: sent before a step execution
- afterStep: sent after a step execution
The body of the message sent is the current StepExecution. Each message
also contains a header to indicate the event type: its key is eventType,
and value is either beforeStep or afterStep.
The target Camel endpoint is configured through batch property endpoint
in job XML. For example,
<job id="camelStepListenerTest" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
<step id="camelStepListenerTest.step1">
<listeners>
<listener ref="camelStepListener">
<properties>
<property name="endpoint" value="#{jobParameters['endpoint']}"/>
</properties>
</listener>
</listeners>
... ...
</step>
</job>An implementation of batch chunk listeners that sends chunk execution events to the configured Camel endpoint. The following are the chunk listener interfaces implemented by this class, and supported types of chunk execution events:
javax.batch.api.chunk.listener.ChunkListenerbeforeChunkonChunkErrorafterChunk
javax.batch.api.chunk.listener.ItemProcessListenerbef oreProcessafterProcessonProcessError
javax.batch.api.chunk.listener.ItemReadListenerbeforeReadafterReadonReadError
javax.batch.api.chunk.listener.ItemWriteListenerbeforeWriteafterWriteonWriteError
javax.batch.api.chunk.listener.RetryProcessListeneronRetryProcessException
javax.batch.api.chunk.listener.RetryReadListeneronRetryReadException
javax.batch.api.chunk.listener.RetryWriteListeneronRetryWriteException
javax.batch.api.chunk.listener.SkipProcessListeneronSkipProcessItem
javax.batch.api.chunk.listener.SkipReadListeneronSkipReadItem
javax.batch.api.chunk.listener.SkipWriteListeneronSkipWriteItem
The body of the message sent is the current ChunkExecutionInfo.
Each message also contains a header to indicate the event type: its key
is eventType, and value is one from the above list.
The target Camel endpoint is configured through batch property endpoint
in job XML. For example,
<job id="camelChunkListenerTest" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
<step id="camelChunkListenerTest.step1">
<listeners>
<listener ref="camelChunkListener">
<properties>
<property name="endpoint" value="#{jobParameters['endpoint']}"/>
</properties>
</listener>
</listeners>
... ...mvn clean install
The test webapp camelReaderWriter uses all the features in jberet-camel.