Camel 中 BeanIO 的动态映射

Dynamic mapping for BeanIO in Camel

我想实现如下目标:

from("direct:dataload")                 
                .beanRef("headerUpdater")
                .log("Log: " + simple("${in.header.contentType}").getText())                    
                //.unmarshal().beanio(simple("${in.header.contentType}").getText(), "content")
                .unmarshal(new BeanIODataFormat(
                        "file://C://Users//admr229//Documents//mappings.xml", "clients"))
                .to("bean:headerFooterValidator")
                .split(body())
                .process(dataValidator).choice()
                .when(header("error").isNotNull())
                .to("seda:saveErrorsForReport").otherwise()
                .to("seda:updateLive")
                .end();

我把不能做的那一行注释掉了。我想从前一个端点的输出传递动态值来初始化 beanio。 我唯一能想到的就是使用收件人列表,它将动态选择一个预定义的端点。因为,就我而言,该端点将使用 beanio 进行解组,这与纯文本的 "activemq:queue:test" 不同。 我希望我已经把我的问题说清楚了。如果您需要任何进一步的详细信息,请告诉我。 我正在使用骆驼 2.15.2

您可以使用数据格式组件 [1],您可以在其中将 beanio 指定为数据格式,并构建 uri 动态 [2]

[1] - http://camel.apache.org/dataformat-component.html

[2] - http://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html

你可以使用做这样的事情,但是,我猜这又不是动态的,因为它需要在启动上下文之前设置属性。

.unmarshal().beanio(映射, streamName)