Apache Camel Unmarshal to Singleton Scoped Bean

时间:2015-04-26 14:48:32

标签: java spring apache-camel

我使用Spring作为我的Bean注册表,我目前使用Java DSL定义了一条路由,如下所示:

function make(x, y, intOptions) {
    var z = x - y    
    if (intOptions.indexOf(z) !== -1) {
        return [y, z];
    } else if (intOptions.length > 1){
        var i = intOptions.length;
        var ans;
        while (i--) {
            ans = make(z, intOptions[i], intOptions.slice(0, i))
            if (ans.length) {
                return [y].concat(ans);
            }
        }        
    }
    return [];
}

它从Netty端点获取XML封送输入,并将其解组到PBX bean。

我原以为我可以将我的结果PBX bean声明为Singleton并让Camel将一个解组的对象传递给处理器,然后处理器更新所述单例bean。这会有用吗?

1 个答案:

答案 0 :(得分:1)

是的,如果casor是注册表中绑定的bean,

/**
 * <a href="http://camel.apache.org/data-format.html">DataFormat:</a>
 * Unmarshals the in body using the specified {@link DataFormat}
 * reference in the {@link org.apache.camel.spi.Registry} and sets
 * the output on the out message body.
 *
 * @param dataTypeRef  reference to a {@link DataFormat} to lookup in the registry
 * @return the builder
 */
@SuppressWarnings("unchecked")
public Type unmarshal(String dataTypeRef) {
    addOutput(new UnmarshalDefinition(dataTypeRef));
    return (Type) this;
}