Mashrur
Mashrur

Reputation: 535

Dynamic mapping for BeanIO in Camel

I would like to achieve something like below:

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();

I have commented out the line which I cannot make. I wanted to pass dynamic values from previous endpoint's output to initialize beanio. Only thing I can think of is using recipient list which will dynamically choose a predefined endpoint. Because, for my case, that endpoint will have unmarshall with beanio, unlike something like "activemq:queue:test", which is purely text. I hope I have made my question clear. Please let me know if you need any further details. I am using camel 2.15.2

Upvotes: 0

Views: 863

Answers (2)

user3776101
user3776101

Reputation: 1

you can use do something like this but, again this not dynamic I guess as it need to have properties set before brining up the context.

.unmarshal().beanio(mapping, streamName)

Upvotes: 0

Claus Ibsen
Claus Ibsen

Reputation: 55555

You can use the data format component [1] where you can specify beanio as the data format, and build the uri dynamic [2]

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

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

Upvotes: 2

Related Questions