I am validating the integration of Spring Batch in our SOA architecture. The goal is that batch programs and online applications use the same business services. These services are implemented as EJBs stateless session beans 3.1 and run on JBoss application server 7.1.
We can have two types of jobs which follow the following designs:
- extraction job: reads from a DB (direct through JDBC), eventually some processing, and XML writing.
- processing job: reads from an XML file, processing (through EJB services) and XML writing
There are several business databases and one central database for spring batch metadata.
I plan to embed the jobs directly in the same J2EE container as EJB services, in order to use the same transaction manager for all the process (JBoss TS), and to optimize performances by not using EJB remote client.
More exactly, the jobs will be launch inside an EJB SLSB component in the same EAR file that business services (so we can work by references).
My interrogations are essentially around transaction aspects:
I see that in a chunk oriented step, with JDBC cursor reader, SB creates a first transaction for initializing step data and then a second one for the chunk itself.
1- why reading needs a transaction since data are just read?
2- There are two different databases (one for SB metadata, one for JDBC cursor Reader) and two different transactions, do we have to use XA transactions? If yes, what is the spring configuration? Declaring a bean JTA transaction manager in Jobs configuration is enough? If no, what is the correct configuration?
3- I saw that we can embed JDBC cursor reader transaction in the same transaction as the chunk one, what is the interest? In this case, I guess it is mandatory to use XA transactions?
4- the Job repository is associated with a transaction manager. If we specify an other transaction manager at the tasklet level, which one is used by the JobRepository to access SB metadata database? What is the correct way to process in my use case?
5- All the SB features are available when using it in a J2EE container? For instance, regarding scaling patterns is it possible to use multithreading knowing that we can call a EJB in the processor of a Step? What about remote scaling?
6- We plan to launch the Jobs through a Scheduler. Since we are in an asyncrhonous way, what is the pattern you recommend for the scheduler to know about Jobs states, ends and so on? We cannot in this case using Jobs exit codes.
Thanks in advance for your responses!