Jdbc 驼峰:聚合器不';t持久化交换属性

Jdbc 驼峰:聚合器不';t持久化交换属性,jdbc,properties,exchange-server,aggregator,Jdbc,Properties,Exchange Server,Aggregator,我正在使用jdbc支持的camel:aggregate,它似乎没有保存Exchange属性。例如,如果我配置了以下路由,并且在聚合完成后以及在重新启动时执行camel:to(log)强制聚合从数据库检索数据之前停止执行,那么camel:to(log)将不会打印属性myProperty <camel:route id="myRoute"> <camel:from uri="direct:in"/> <camel:setProperty propert

我正在使用jdbc支持的camel:aggregate,它似乎没有保存Exchange属性。例如,如果我配置了以下路由,并且在聚合完成后以及在重新启动时执行camel:to(log)强制聚合从数据库检索数据之前停止执行,那么camel:to(log)将不会打印属性myProperty

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

    <camel:setProperty propertyName="myProperty">
        <camel:constant>myPropertyValue</camel:constant>
    </camel:setProperty>

    <camel:aggregate strategyRef="myStrategy" aggregationRepositoryRef="myAggregationRepo" discardOnCompletionTimeout="true" completionTimeout="86400000" >
        <camel:correlationExpression>
            <camel:simple>${property.partlastcorrelationkey}</camel:simple>
        </camel:correlationExpression>
        <camel:completionPredicate>
            <camel:simple>${property.partlastcorrelationwaitmore} == false</camel:simple>
        </camel:completionPredicate>

        <camel:to uri="log:com.test?showAll=true"/>

    </camel:aggregate>
</camel:route>

myPropertyValue
${property.partlastcorrelationkey}
${property.partlastcorrelationwaitmore}==false
我的聚合存储库按以下方式配置:

<bean id="myAggregationRepo" class="org.apache.camel.processor.aggregate.jdbc.JdbcAggregationRepository" init-method="start" destroy-method="stop">
    <property name="transactionManager" ref="transactionManager"/>
    <property name="repositoryName" value="PROC_AGG"/>
    <property name="dataSource" ref="oracle-ds"/>
    <property name="lobHandler">
        <bean class="org.springframework.jdbc.support.lob.OracleLobHandler">
            <property name="nativeJdbcExtractor">
                <bean class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"/>
            </property>
        </bean>
    </property>
</bean>


使用聚合器时如何保存属性?我会自己回复。正如代码中所示,JDBCC不允许在使用数据库备份聚合器时保存属性:

public final class JdbcCamelCodec {
    public byte[] marshallExchange(CamelContext camelContext, Exchange exchange) throws IOException {
        // use DefaultExchangeHolder to marshal to a serialized object
        DefaultExchangeHolder pe = DefaultExchangeHolder.marshal(exchange, false);
        // add the aggregated size property as the only property we want to retain
        DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_SIZE, exchange.getProperty(Exchange.AGGREGATED_SIZE, Integer.class));
        // add the aggregated completed by property to retain
        DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_COMPLETED_BY, exchange.getProperty(Exchange.AGGREGATED_COMPLETED_BY, String.class));
        // add the aggregated correlation key property to retain
        DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_CORRELATION_KEY, exchange.getProperty(Exchange.AGGREGATED_CORRELATION_KEY, String.class));
        // persist the from endpoint as well
        if (exchange.getFromEndpoint() != null) {
            DefaultExchangeHolder.addProperty(pe, "CamelAggregatedFromEndpoint", exchange.getFromEndpoint().getEndpointUri());
        }
    return encode(pe);
}
基本上,问题在于这一行,false的意思是:不保存属性

DefaultExchangeHolder pe = DefaultExchangeHolder.marshal(exchange, false);
头和主体是数据库中唯一存储的