Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache camel 将对象参数传递给setHeader中的方法-camel_Apache Camel - Fatal编程技术网

Apache camel 将对象参数传递给setHeader中的方法-camel

Apache camel 将对象参数传递给setHeader中的方法-camel,apache-camel,Apache Camel,我不熟悉Camel,并试图找到一种在SetHeader中将对象传递给方法的方法 但是我犯了个错误 org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: getCustProcessDir('${header.CUST}') on null due to: org.apache.camel.component.bean.ParameterBindingException: Er

我不熟悉Camel,并试图找到一种在SetHeader中将对象传递给方法的方法

但是我犯了个错误

org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: getCustProcessDir('${header.CUST}') on null due to: org.apache.camel.component.bean.ParameterBindingException: Error during parameter binding on method: public java.lang.String CustDao.getCustProcessDir(Cust) at parameter #0 with type: class Cust with value type: class java.lang.String and value: Cust@199b87b5
    at org.apache.camel.language.bean.BeanExpression.invokeOgnlMethod(BeanExpression.java:430) ~[camel-bean-3.3.0.jar:3.3.0]
    at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:164) ~[camel-bean-3.3.0.jar:3.3.0]
代码:

fromF("file:C:/Users/a/Documents/Development/input/"
                + "?recursive=false&noop=true&delay=20000&readLockLoggingLevel=WARN&shuffle=true"
                + "&readLock=idempotent&idempotentRepository=#fileRepo&readLockRemoveOnCommit=true&readLockRemoveOnRollback=true&delete=true&moveFailed=%s"
                , "C:/Users/a/Documents/Development/rejected/")
        .routeId("fileMoveRoute")
        .process(exchange -> {
            exchange.getMessage().setHeader("Application_ID", appInfo.getInstanceId());
        })
        .threads(appInfo.getThreadCount())
        .setHeader("CUST", method(CustDao.class, "getInboundCustWithfile('${header.CamelFilePath}')"))
        .setHeader("PROCESS_DIR", method(CustDao.class, "getCustProcessDir('${header.CUST}')"))
        ...
    
public String getCustProcessDir(Cust cust) {
    return appInfo.getDir() + cust.getCustprofid() + "/hold/";
    }   



public class Cust {

  private int custid;
  private String custprofid;
  ...
 
}
首先
setHeader(“CUST”)
起作用,我相信
Header(“CUST”)
已经返回了对象值

但我不知道它是如何储存在骆驼。我试图在调试期间从“变量”窗口中找到它们,但未能找到它们。变量太多,无法查看。。。调试期间在哪里可以找到此标头值

如何将对象值传递给该方法

.setHeader("PROCESS_DIR", method(CustDao.class, "getCustProcessDir('${header.CUST}')"))
还是有更好的方法在路由过程中传递/处理对象


谢谢,

我想像
${header.CUST}
这样的表达式周围的单引号是问题所在,因为
RuntimeBeanExpressionException
抱怨它收到了字符串
Cust@199b87b5
而不是
Cust
对象

看一看这张照片。方法参数表达式周围没有单引号

关于头变量的存储:它们存储在Camel上

Exchange -> Message -> Headers
Exchange -> ExchangeProperties

非常漂亮的接球!有道理。不知道为什么我没有看到;)我真的很感激!