camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "wow" <>
Subject what's the problem with bean expression
Date Tue, 29 Nov 2011 05:45:51 GMT
I use camel 2.8.0 with servicemix4.3. I set up a dynamic router by camel-context.xml. as follows:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns=""


    <bean id="bizTypeDR" class="com.hongbo.cobweb.master.router.BizTypeDynamicRouter" init-method="init">
        <property name="gatewayUri" value="jbi:service:"
        <property name="storeUri" value="jbi:service:"
        <property name="storeFactoryName" value="MongoMessageStore" />
    <camelContext id="camelContext" xmlns="">
            <from uri="jbi:service:"
                <method ref="bizTypeDR" method="route"/>

bizTypeDR bean: 
    public String route(@Header(MessageHeader.CW_MSG_BIZ_TYPE) String bizType, Exchange exchange)
        // query a database to find the best match of the endpoint based on the input parameteres

        // return the next endpoint uri, where to go. Return null to indicate the end. 
        if (started.get()) { 
            if (exchange.hasOut()) { 
                return null; 
            if (types != null && types.size() > 0 && bizType != null) {

                WrapperMessageBizType mbt = types.get(bizType); 
                if (mbt != null && mbt.getSaIds() != null && mbt.getSaIds().size()
> 0) { 
                    exchange.getIn().setHeader(MessageHeader.CW_INNER_MSG_BIZ_URI, mbt.getUri());

                    return gatewayUri; 
        return storeUri; 

It finish selecting one approach(gatewayUri or storeUri) 

But I debug the camel-su. When (gatewayUri or storeUri) downflow components return an exchange
with out message(it contains body and headers), camel ignore headers and think the body is
next uri in BeanExpress. Is it a bug?? Camel should return the exchange to upflow component(http)
in servicemix. 

BeanExpress code: 
line 161-163 
                result = resultExchange.getOut().getBody(); 
In line 163, resultExchange is ok. It contains In Message and Out Message returned by downflow
components in servicemix. The out Message has headers and body. but 163, camel bean expression
only cares about the body of out message and ignore headers of out message. 

How can I use dynamic router in camel. It can return entirely exchange from downflow components
to upflow component. 

                                                   thank you very much! 

View raw message