카테고리 없음

Spring Batch에서 db를 사용하여 여러 리더를 구현하는 방법

기록만이살길 2021. 2. 27. 07:29
반응형

Spring Batch에서 db를 사용하여 여러 리더를 구현하는 방법

1. 질문(문제점):

이 코드는 Spring Batch 버전 1의 버전입니다. org.springframework.batch.item.database.IbatisDrivingQueryItemReader 클래스는 현재 버전에서 더 이상 사용할 수 없기 때문에이 코드를 버전 4로 마이그레이션하는 데 문제가 있습니다.

아래 코드의 프로세스는 withdrawalIbatisKeyGenerator 빈이 먼저 실행되고 해당 빈의 출력에서 ​​ibatisWithdrawalReader 빈에서 사용됩니다.

내 질문은 두 빈이 서로 종속성을 갖기 때문에이 리더를 현재 버전으로 구현하는 방법입니다.

<bean id="ibatisWithdrawalReader"
        class="org.springframework.batch.item.database.IbatisDrivingQueryItemReader">
        <property name="detailsQueryId"
            value="withdrawalTransactionDao.getWithdrawalTransaction" />
        <property name="sqlMapClient" ref="sqlMap" />
        <property name="keyCollector"
            ref="withdrawalIbatisKeyGenerator" />
    </bean>



<bean id="withdrawalIbatisKeyGenerator"
        class="ph.pnblife.julia.batch.BatchKeyCollector">
        <property name="drivingQuery"
            value="withdrawalTransactionDao.getWithdrawalTransactionKey" />
        <property name="restartQueryId"
            value="withdrawalTransactionDao.restartWithdrawalTransaction" />
        <property name="sqlMapClient" ref="sqlMap" />
        <property name="parameters">
            <list>
                <value>%%pricing_date_ibatis:date:pricing_date</value>
                <value>%%policy_number:string:pol_no</value>
                <value>%%version_no:string:version_no</value>
                <value>%%start_date:date:start_dt</value>
                <value>%%endt_type:string:endt_code</value>
            </list>
        </property>
        <property name="isKeyAMap">
            <value type="java.lang.Boolean">true</value>
        </property>
    </bean>

2. 해결방안:

withdrawalIbatisKeyGenerator빈은로 등록 할 수 StepExecutionListener판독기에 의해 요구되는 데이터가 생성된다 StepExecutionListener#beforeStep방법.

65785965
반응형