gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 08:31:20 25 4
gpt4 key购买 nike

我是 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com