如何避免重复spring <task:scheduled ... =“”>?</task:scheduled>

时间:2014-08-11 08:45:57

标签: java spring

考虑applicationContext.xml的以下片段:

<task:scheduler id="xfsXmlProducer" pool-size="1" />

<task:scheduler id="xfsXmlConsumer" pool-size="${transactionqueue.consumerThreadsCount}" />

<task:scheduled-tasks scheduler="xfsXmlProducer">
    <task:scheduled ref="xmlFileProducerJob" method="run" fixed-delay="3000"/>
</task:scheduled-tasks>

<task:scheduled-tasks scheduler="xfsXmlConsumer">
    <task:scheduled ref="xmlFileConsumerJob" method="run" fixed-delay="10"/>
    <task:scheduled ref="xmlFileConsumerJob" method="run" fixed-delay="10"/>
    <task:scheduled ref="xmlFileConsumerJob" method="run" fixed-delay="10"/>
    <task:scheduled ref="xmlFileConsumerJob" method="run" fixed-delay="10"/>
    <task:scheduled ref="xmlFileConsumerJob" method="run" fixed-delay="10"/>
</task:scheduled-tasks>

<bean id="xmlFileConsumerJob"
      class="xxxx.parser.job.XmlFileConsumerJob"
      lazy-init="true"
      scope="prototype"/>

<bean id="xmlFileProducerJob"
      class="xxxx.parser.job.XmlFileProducerJob" lazy-init="true">
    <property name="transactionBulkSize" value="${transactionqueue.bulkSize}" />
</bean>

有没有办法避免重复

<task:scheduled ref="xmlFileConsumerJob" method="run" fixed-delay="10"/>

我想指定一些工人。

0 个答案:

没有答案