Camel pollEnrich 仅在第二次起作用
Camel pollEnrich only works second time
我有一条由 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
我第一次触发这条路线时总是得到 "Cannot read file. Body is null"。
但如果我再次触发它,它就会正常工作并且文件得到处理。
知道为什么吗?
P.S。我试图将 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 或其他值。
我有一条由 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
我第一次触发这条路线时总是得到 "Cannot read file. Body is null"。
但如果我再次触发它,它就会正常工作并且文件得到处理。
知道为什么吗?
P.S。我试图将 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 或其他值。