我使用带有hazelcast组件的camel,当交换通过hazelcast seda时遇到交换标题的问题。
我需要从目录轮询文件并将交换发送到seda hazelcast队列(以处理集群中的交换)。
这种情况有一个简单的例子。 有两条路径在其他JVM中运行:
首先用于轮询文件:
from("file:someFromFolder")
.to("hazelcast:seda:queue?hazelcastInstance=#hazelcast-instance");
第二个处理了这个:
from("hazelcast:seda:queue?hazelcastInstance=#hazelcast-instance")
.to("file:someToFolder");
当我尝试阅读Exchange.FILE_NAME
或其他人的标题时,我意识到它们是空的。
通过hazelcast seda组件传输交换时是否可以保存标头?
修改
当我在生成器路由端点上设置transferExchange=true
作为选项时,我会捕获异常:
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
org.apache.camel.RuntimeExchangeException: Message body of type org.apache.camel.component.file.GenericFile is not supported by this marshaller. on the exchange: Exchange[ID-DF-240815-MS12-60568-1487853045890-0-12][file.txt]
at org.apache.camel.impl.DefaultExchangeHolder.marshal(DefaultExchangeHolder.java:99)
at org.apache.camel.impl.DefaultExchangeHolder.marshal(DefaultExchangeHolder.java:83)
at org.apache.camel.component.hazelcast.seda.HazelcastSedaProducer.checkAndStore(HazelcastSedaProducer.java:55)
at org.apache.camel.component.hazelcast.seda.HazelcastSedaProducer.process(HazelcastSedaProducer.java:42)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:141)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:442)
at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:214)
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:178)
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
那么marshaller是否可以尝试序列化所有文件数据?
答案 0 :(得分:0)
您需要在端点上设置transferExchange=true
作为选项。默认情况下,它只是传输的邮件正文。您可以在文档中找到此信息:http://camel.apache.org/hazelcast-component.html#HazelcastComponent-seda