简体   繁体   中英

Setting Property in Apache Camel in XML

I'm new to apache camel. Need help on the below.

I have 2 routes. From route A I'm sending only 1 property to another route using a method call. like

        <camel:route id="processMessageRoute">
        <camel:from uri="direct:processMessageRoute" /> 

        <camel:setProperty propertyName="MessageMap">
            <camel:method bean="ServiceBean" method="initMessageMap" />
        </camel:setProperty>

        <camel:setProperty propertyName="MessageBelongerMap">
            <camel:method bean="ServiceBean" method="initMessageBelongerMap" />
        </camel:setProperty>

    <camel:to uri="bean:ServiceBean?method=saveMessageData(${property.MessageBelongerMap})" />

Inside ServiceBean class, I have

public boolean saveMessageData(Map<String, Object> MessageBelongerMap) {

    producerTemplate.requestBody("direct:processMessage", MessageBelongerMap);

    return true;

Now my problem is I need to pass both the properties MessageMap, MessageBelongerMap but I don't see any option here. Need help on this?

Just add a 2nd parameter in your bean method

public boolean saveMessageData(Map<String, Object> MessageBelongerMap,
                               Map<String, Object> MessageMap) {

And then bind to the 2nd parameter from Camel

<camel:to uri="bean:ServiceBean?method=saveMessageData(${property.MessageBelongerMap}, ${property.MessageMap})" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM