我发现这originalPayload
与message.originalPayload
groovy 表达式不同。也就是说,以下转换器不会做同样的事情:
与originalPayload
:
<expression-transformer evaluator="groovy" expression="originalPayload" />
与message.originalPayload
:
<expression-transformer evaluator="groovy" expression="message.originalPayload" />
以下 mule 配置和测试用例可用于重现该问题:
<mule ...>
<flow name="test">
<vm:inbound-endpoint name="test.Name" path="test.Path"
exchange-pattern="request-response" />
<expression-transformer evaluator="string" expression="bar" />
<expression-transformer evaluator="groovy" expression="originalPayload" />
<!-- or alternatively -->
<!-- <expression-transformer evaluator="groovy" expression="message.originalPayload" /> -->
</flow>
</mule>
测试用例可以是:
@Test
public void transformers() throws MuleException {
final MuleClient client = muleContext.getClient();
final MuleMessage reply = client.send("vm://test.Path", 1, null, RECEIVE_TIMEOUT);
assertEquals(1, reply.getPayload());
}
替代方案message.originalPayload
按预期工作。一个originalPayload
没有,日志中显示了以下异常:
Exception stack is:
1. Expression Evaluator "groovy" with expression "originalPayload" returned null
but a value was required. (org.mule.api.expression.RequiredValue Exception)
我可能做错了什么?
谢谢。