我已编写此配置文件以从数据库读取并写入CSV文件。
<?xml version="1.0" encoding="UTF-8"?>
<!-- Start imports -->
<import resource="launch-context.xml"/>
<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
<!-- End imports -->
<job id="DLM" xmlns="http://www.springframework.org/schema/batch">
<!-- Step 1 -->
<step id="siebelToStaging" next="generateControlReport">
<tasklet transaction-manager="transactionManager">
<chunk reader="DbReader" writer="outputFileWriter" commit-interval="10"> </chunk>
<!--
<listeners>
<listener ref="dbReaderStepExecutionListener"/>
</listeners>
-->
</tasklet>
</step>
<!-- Step 2 -->
<step id="generateControlReport">
<tasklet ref="generateControlReportTasklet"/>
</step>
<listeners>
<listener ref="jobListener"/>
</listeners>
</job>
<!-- End job -->
<bean id="jobListener" class="my.com.tm.hsbb.eai.batch.listener.GenericJobExecutionListener">
<property name="eaiJobExecution" ref="eaiJobExecution"/>
<property name="dao" ref="dao"/>
</bean>
<!--
<bean id="dbReaderStepExecutionListener" class="my.com.tm.hsbb.eai.batch.listener.DbStepExecutionListenerImpl">
<property name="eaiJobExecution" ref="eaiJobExecution"/>
<property name="updLastWritableStepCtxId" value="true"/>
<property name="updLastReadableStepCtxId" value="true"/>
</bean>
-->
<!-- Assigning values to parameter variable -->
<bean id="eaiJobExecution" class="my.com.tm.hsbb.eai.batch.job.EaiJobExecution">
<property name="parameter">
<bean class="my.com.tm.hsbb.eai.batch.job.Parameter">
<property name="fileDateFmt" value="yyyyMMDDhhmmss"/>
<property name="fileHeaderDateFmt" value="yyyyMMDDhhmmss"/>
<property name="totalRecordsFmt" value="10N"/>
<property name="sequenceFmt" value="4N"/>
<property name="sequenceName" value="003_SEQ"/>
<property name="outputDir" value="/outbox/new"/>
<property name="reportDir" value="/ctlrpt"/>
</bean>
</property>
</bean>
<bean id="dao" class="my.com.tm.hsbb.eai.batch.dao.BatchJobDao">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="generateControlReportTasklet" class="my.com.tm.hsbb.eai.batch.tasklet.GenerateControlReportTasklet">
<property name="ctrlReportDir" ref="reportDirResource"/>
</bean>
<bean id="controlReport" class="my.com.tm.hsbb.eai.batch.dataobject.ControlReport"/>
<bean id="reportDirResource" class="org.springframework.core.io.FileSystemResource">
<constructor-arg value="../ctlrpt"/>
</bean>
<!-- ItemReader which reads from Siebel database and returns the row mapped by rowMapper - START-->
<bean id="DbReader"
class="org.springframework.batch.item.database.JdbcCursorItemReader">
<property name="dataSource" ref="DataSource" />
<property name="sql">
<value>
<![CDATA[SELECT STX.serial_num
FROM cityDB
WHERE MODEM.prod_id = (SELECT row_id
FROM s_prod_int
WHERE name = 'Modem'
AND ROWNUM < 2)
AND status_cd <> 'Inactive'
AND par_asset_id = row_id]]>
</value>
</property>
<property name="rowMapper">
<bean class="my.com.tm.hsbb.eai.batch.transform.DynamicLineManagementRowMapper" />
</property>
</bean>
<!-- ItemReader which reads from database and returns the row mapped by rowMapper - END-->
<!-- SBL DB Connectivity configuration -->
<bean id="DataSource" class="oracle.jdbc.pool.OracleDataSource">
<property name="driverType" value="${db_driver}"/>
<property name="URL" value="${db_url}"/>
<property name="user" value="${db_user}"/>
<property name="password" value="${db_password}"/>
</bean>
<!-- Writing the file - START -->
<bean id = "outputFileWriter" class = "org.springframework.batch.item.file.FlatFileItemWriter" scope="step">
<property name = "resource" value = "file:/new/LINE_ICP_#{jobParameters[dateCreated]}#{jobParameters[timeCreated]}.txt"/>
<property name = "lineAggregator">
<bean class = " org.springframework.batch.item.file.transform.PassThroughLineAggregator"/>
</property>
</bean>
<!-- Writing the file - END -->
这是我编写过的最简单的spring-batch配置文件,但这是批处理作业,耗时9个小时才写出一个大小为10MB,有69507行的文件。我已经取消了大多数可能涉及可能导致瓶颈的类和接口的行,但是仍然需要很长时间。
请问有人可以在减少处理时间方面做些什么?如果我提供的信息不足,您可以告诉我。 (因为系统将它们识别为超链接,所以必须删除其中的一些名称空间,而且sql查询也已缩短) 预先感谢。