Execute database operations inside a chunck orientad step

152 views Asked by At

I have a chunk oriented processor in the form "reader / processor / writer" called Job1. I have to execute database EJB operations after this job ends, if possible, in the same transaction. I have others jobs (implemented by Tasklets) that I could do this in a simply manner. I this jobs I simply call this operations in tasklet, before finish exeute method. But in this case I don't know the right way to do. In a first try I implemented it by a step listener (outside transaction). But I cannot, because there are uma architecture rule in my company to don't call database operations in listeners. I could execute it after this step in another step in a tasklet and I will come this way if I don't find a better one, but moreover if it's possible I like to execute this operations in the same transaction of Job1.

1

There are 1 answers

0
Michael Minella On BEST ANSWER

A couple notes:

  1. In a chunk based step (reader/processor/writer), typically you'll have multiple transactions. One for each chunk.
  2. Because of 1, you typically can't do a db call in at the end of a step that is in the same transaction as the items were processed in. They were processed in multiple transactions.

That being said, from what it sounds like, the best option would be to put your call in another step after the chunk based one.