quartz-scheduler - Spring Integration 2 与 Quartz 调度器

标签 quartz-scheduler spring-integration

我是 Spring Integration 的新手。

我已经配置了一个 Spring 文件 inbound-channel-adapter,例如

<file:inbound-channel-adapter channel="channel1" directory="${location}" prevent-duplicates="true" filename-pattern="*.csv">
        <si:poller>
            <si:interval-trigger interval="1000"/>
        </si:poller>
</file:inbound-channel-adapter>

<si:service-activator input-channel="channel1" output-channel="channel2" ref="filenameGenerator" method="generate"/>

现在一切正常。 但是这个需要部署在集群环境中。我想确保集群中的多个实例不会尝试读取同一个文件。那么这会在这样的环境中工作吗?

如果不是,我可以像这样使用 Quartz 调度程序吗:

    <file:inbound-channel-adapter channel="channel1" directory="${location}" prevent-duplicates="true" filename-pattern="*.csv">
             <si:poller task-executor="taskExecutor" fixed-rate="1000"/>
    </file:inbound-channel-adapter>

    <si:service-activator input-channel="channel1" output-channel="channel2" ref="filenameGenerator" method="generate"/>

    <bean id="taskExecutor" class="org.springframework.scheduling.quartz.SimpleThreadPoolTaskExecutor">
        <property name="threadCount" value="20"/>
        <property name="threadNamePrefix" value="consumer"/>
    </bean>

这能解决我的问题吗?? 还是我必须使用交易?

我希望问题很清楚。

谢谢, 阿迪

最佳答案

When multiple processes are reading from the same directory it can be desirable to lock files to prevent them from being picked up concurrently. To do this you can use a FileLocker

查看有关文件柜的文档 here .看起来你可以做这样的事情:

<file:inbound-channel-adapter ... >
  <file:nio-locker/>
</file:inbound-channel-adapter>

When multiple processes are reading from the same directory it can be desirable to lock files to prevent them from being picked up concurrently. To do this you can use a FileLocker

关于quartz-scheduler - Spring Integration 2 与 Quartz 调度器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8897183/

相关文章:

java - 我可以使用哪种 Spring 集成模式?

spring - 如何在特定时间内处理一条消息?

java - 如何将路径变量分配给 java dsl http 入站网关中的 header ?

java - 定期到期通知——如何避免同一条目收到重复通知?

java - nextFireTime 和开始时间不一致

java - 我需要为立即触发设置什么样的失火指令?

java - 从 Spring 3 迁移到 Spring 4 - org.springframework.scheduling.quartz.CronTriggerBean

java - org.quartz.jobStore.clusterCheckinInterval 的推荐值

java - spring integration中如何并行同步处理?

java - Spring 集成: Poller acting weird