Camel pollEnrich仅次于第二次

时间:2018-02-06 18:08:55

标签: java apache-camel smb

我有一个由宁静引发的直接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

我第一次触发此路线时,我总是得到"无法读取文件。身体是空的"。 但是,如果我再次触发它,它然后工作正常,文件得到处理。
知道为什么吗?

P.S。我试图在DEBUG模式下设置CAMEL,但我很难理解它的作用。我第一次运行它时得到的结果如下:

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]

1 个答案:

答案 0 :(得分:1)

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