Good day,
I have a Spring batch, that using org.springframework.batch.item.support.CompositeItemWriter
to write data into db.
The following is the writer code in my xml:
<bean id="iReturnCompositeTableWriter" class="org.springframework.batch.item.support.CompositeItemWriter">
<property name="delegates">
<list>
<ref bean="iReturnTableWriter5" />
</list>
</property>
</bean>
<bean id="iReturnTableWriter5" class="com.batch.job.writer.IReturnTableWriter">
<property name="assertUpdates" value="false" />
<property name="itemSqlParameterSourceProvider">
<!-- Our Mapper for table writer -->
<bean class="com.batch.job.writer.mapper.IReturnWriterTableMapper" />
</property>
<!-- Put in your INSERT, UPDATE, DELETE SQL here -->
<property name="sql"
value="UPDATE ADM.TRX
SET STATUS = 'FAIL'
WHERE INTERNALREFERENCENO = :theirTraceNum" />
<property name="dataSource" ref="dataSource" />
</bean>
And the following is code of IReturnTableWriter
class:
public class IReturnTableWriter extends JdbcBatchItemWriter< TrxVO >
implements StepExecutionListener, ItemWriteListener< TrxVO > {
public void afterWrite(List<? extends BulkPaymentVO> arg0) {
}
public void beforeWrite(List<? extends BulkPaymentVO> arg0) {
}
public void onWriteError(Exception arg0, List<? extends BulkPaymentVO> arg1) {
}
public ExitStatus afterStep(StepExecution arg0) {
return null;
}
public void beforeStep(StepExecution arg0) {
}
}
And the following is the code of IReturnWriterTableMapper
class:
public class IReturnWriterTableMapper implements
ItemSqlParameterSourceProvider< IbgReturnVO > {
public SqlParameterSource createSqlParameterSource(TrxVO trxVO) {
return new BeanPropertySqlParameterSource(trxVO);
}
}
The batch log show this batch run successful without any error. The successful count is match with my input file row count. In the log, I also saw that its being read by the reader and store into trxVO
object.
However, there is 1 of the record did not updated to database in production, even the success count is correct. I grab the input file and run in SIT, UAT and its working fine. From the log, I cant see it log about the update query.
I actually already enable log level to trace for org.springframework.batch
and org.springframework.jdbc
in logback.xml:
<logger name="org.springframework.batch">
<level value="TRACE" />
</logger>
<logger name="org.springframework.jdbc">
<level value="TRACE" />
</logger>
And in log, I can saw its already take effect:
15:44:19,173 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.springframework.batch level set to TRACE
15:44:19,173 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.springframework.jdbc level set to TRACE
I would like to ask the way on how to enable more log for the writer, so that I can troubleshoot what is happening.
Or, if you have more useful idea, or suggestion, please advise.
The
JdbcBatchItemWriter
uses spring-jdbc APIs behind the scene, so you can set the log level todebug
fororg.springframework.jdbc
package.I would also enable debug logs for
org.springframework.batch
as well.