Using Batch API with JBoss EAP 6

Today I'm going to demonstrate how to run the Batch API on JBoss EAP 6. As you probably know, Jboss EAP 6 (and AS 7) features the Java EE 6 API which does not include the Batch API, that is part of Java EE 7.

In order to run the Batch API on JBoss EAP 6 we need to patch the installation of the application server by downloading the backport of Batch API subsystem to available at: https://github.com/fcorneli/jberet-eap6

  • Download the latest dist (http://www.e-contract.be/maven2/org/jberet/eap6/eap6-batch-dist/1.0.2/eap6-batch-dist-1.0.2.zip)
  • Unzip it under the modules folder of JBoss EAP 6
  • Modify the modules/system/layers/base/javaee/api/main/module.xml:

Include the following dependency:

<dependencies>
	
...
	
   <module name="javax.batch.api" export="true"/>
</dependencies>

We need to create a configuration ad hoc (or simply change one of your existing configurations):

Create a copy of your configuration file (e.g. standalone.xml):

cp standalone.xml standalone-batch.xml

Now add the batch extension at the top of it:

<extensions>

...

    <extension module="org.wildfly.extension.batch"/>

</extensions>

Next, within your profile (I've added it at the beginning) add the batch subsystem:

<subsystem xmlns="urn:jboss:domain:batch:1.0">
	<job-repository>
		<jdbc jndi-name="java:jboss/datasources/ExampleDS"/>
	</job-repository>
	<thread-pool>
		<max-threads count="10"/>
		<keepalive-time time="30" unit="seconds"/>
	</thread-pool>
</subsystem>

Now start the application server:

standalone.sh -c standalone-batch.xml

Now connect to the CLI and verify that the subsystem batch is available:

[standalone@localhost:9999 /] /subsystem=batch:read-resource
{
    "outcome" => "success",
    "result" => {
        "job-repository-type" => "jdbc",
        "job-repository" => {"jdbc" => undefined},
        "thread-factory" => undefined,
        "thread-pool" => {"batch" => undefined}
    }
}

Congratulations! You have successfully patched EAP 6 to run the Batch API!

Follow us on Twitter