Sep 15th, 2012, 07:41 AM
Passing Data Between Steps
I am trying to write an interface using spring integration and batch as below
If there are n no records in file then n no records should be inserted into MySQl and Oracle database.
Further 10 JMS MQ messages should be generated.
I did the process till MySql DB insert. I can write a task let (chunk) which has itemRead and itemWriter.
But further how to write the data in Oracle DB and JMS? How to pass the data between steps in batch.
And very important is everything should be transacted using distributed transaction (XA). Somewhere I read that Spring batch commit after every step. How to propagate the transaction in this case?
Please suggest the solution.
Chaitanya S. Yardi.
Sep 17th, 2012, 10:46 AM
Can't you make use of JobExecutionContext to pass data between steps? Tx startes at reader and goes through processor and ends at the writer. so try to have all the queries that you need to do in a single tx within this (reader -processor-writer)- and if you have your transactional attributes as PROPAGATION_REQUIRED, you would get what you need
Sep 18th, 2012, 05:46 AM
I have already tried transaction-attributes propagation="REQUIRED" but it did not worked.
I checked the source of TaskletStep.java and there is transaction commit/rollback. Therefore transactions is getting completed.
In addition to this, definitely we can pass the data using JobExecutionContext, But How to tell next Steps' writer to refer JdbExecutionContext .
Further can we have such Tasklet Step which will not have reader but only writer.
Tags for this Thread