SimpleBuilder 在骆驼中的使用
SimpleBuilder usage in camel
我有以下处理器,当我从我的路线 运行 它时,我收到以下错误。我知道交换主体不为空,您可以在下面的日志中看到它。我在这里使用 SimpleBuilder 有什么问题?
public class UpdateCustomerProcessor implements Processor {
public static final Logger log = LoggerFactory.getLogger(UpdateCustomerProcessor.class);
public void process(Exchange exchng) throws Exception {
Customer c = (Customer) exchng.getIn().getBody(Object[].class)[0];
System.out.println("Updating customer " + c.getFirstName() + " " + c.getLastName());
System.out.println(SimpleBuilder.simple("Hello ${body.getFirstName()}").evaluate(exchng, String.class));
exchng.getOut().setBody(new Object[] {});
}
}
log->Updating customer aaa bbb
error-> org.apache.cxf.interceptor.Fault: Failed to invoke method: .getFirstName() on null due to: org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: getFirstName() on null
我无法理解 "null" 异常,因为 exchange in 似乎已满。尽管如此,你的表达看起来不正确 - 因为你的 exchange.in 似乎包含一个数组,它应该是:
SimpleBuilder.simple("Hello ${body[0].firstname}").evaluate(exchng, String.class))
我有以下处理器,当我从我的路线 运行 它时,我收到以下错误。我知道交换主体不为空,您可以在下面的日志中看到它。我在这里使用 SimpleBuilder 有什么问题?
public class UpdateCustomerProcessor implements Processor {
public static final Logger log = LoggerFactory.getLogger(UpdateCustomerProcessor.class);
public void process(Exchange exchng) throws Exception {
Customer c = (Customer) exchng.getIn().getBody(Object[].class)[0];
System.out.println("Updating customer " + c.getFirstName() + " " + c.getLastName());
System.out.println(SimpleBuilder.simple("Hello ${body.getFirstName()}").evaluate(exchng, String.class));
exchng.getOut().setBody(new Object[] {});
}
}
log->Updating customer aaa bbb
error-> org.apache.cxf.interceptor.Fault: Failed to invoke method: .getFirstName() on null due to: org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: getFirstName() on null
我无法理解 "null" 异常,因为 exchange in 似乎已满。尽管如此,你的表达看起来不正确 - 因为你的 exchange.in 似乎包含一个数组,它应该是:
SimpleBuilder.simple("Hello ${body[0].firstname}").evaluate(exchng, String.class))