gpt4 book ai didi

java - Camel pollEnrich 只能在第二次起作用

转载 作者:行者123 更新时间:2023-12-02 11:40:05 31 4
gpt4 key购买 nike

我有一条由restful触发的直接Camel路线。 Restful 传递 Exchange 主体内的文件名(需要处理)。路线很简单:

from("direct:myRoute")
.log("Reading file with name ${in.body}")
.pollEnrich().simple(inboundUri).timeout(5000)
.choice()
.when(body().isNull())
.log("Cannot read file. Body is null")
.otherwise()
.log("Processing file: ${in.headers.CamelFileAbsolutePath}")
...

其中 inboundUri 是:

smb://DOMAIN;username:password@myLocation/myFolder/?include=${in.body}.csv&delay=5000&noop=true&idempotent=false&readLock=none&recursive=false&sortBy=reverse:file:modified

第一次触发此路由时,我总是收到“无法读取文件。正文为空”。但如果我再次触发它,它就会正常工作并且文件会被处理。
知道为什么吗?

附注我尝试将 CAMEL 设置为 Debug模式,但我很难理解它的作用。我第一次运行它时,我得到如下信息:

DefaultCamelContext : Using ComponentResolver: org.apache.camel.impl.DefaultComponentResolver@1016b44e to resolve component with name: smb
ResolverHelper : Lookup Component with name smb in registry. Found: null
ResolverHelper : Lookup Component with name smb-component in registry. Found: null
DefaultComponentResolver : Found component: smb via type: org.apacheextras.camel.component.jcifs.SmbComponent via: META-INF/services/org/apache/camel/component/smb
DefaultManagementAgent : Registered MBean with ObjectName: org.apache.camel:context=camel-1,type=components,name="smb"
...
PollEnricher : Consumer received no exchange
FilterProcessor : Filter matches: true for exchange: Exchange[ID-server-43626-1517937470434-0-2]

第二次输出要短得多,主要区别似乎是:

ServiceHelper : Resuming service Consumer[smb://DOMAIN;username:password@myLocation/myFolder/?include=${in.body}.csv&delay=5000&noop=true&idempotent=false&readLock=none&recursive=false&sortBy=reverse:file:modified]
PollEnricher : Consumer received: Exchange[]
FilterProcessor : Filter matches: false for exchange: Exchange[ID-server-43626-1517937470434-0-4]

最佳答案

将入站 uri 中的延迟值设置为较低的值,因为它的延迟为 5000,这与超时相同,因此没有足够的时间运行。将其设置为 1000 或 500 或其他值。

关于java - Camel pollEnrich 只能在第二次起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48649335/

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