我正在尝试#[process:processName:valueToProcess]
在我的流程中使用该表达式。
这是我的流程配置:
<flow name="exampleFlow">
<quartz:inbound-endpoint jobName="job1" cronExpression="0/5 * * * * ?" connector-ref="quartzConnector">
<quartz:event-generator-job>
<quartz:payload>foo</quartz:payload>
</quartz:event-generator-job>
</quartz:inbound-endpoint>
<logger message="#[process:test:#[payload]]" level="INFO"/>
</flow>
<sub-flow name="test" doc:name="test">
<component class="com.myComp.ComponentTest" doc:name="Java"/>
</sub-flow>
这是我的 Java 组件:
package com.myComp;
public class ComponentTest
{
public String test(String s)
{
return s + "bar";
}
}
当计算表达式时,问题就来了#[process:test:#[payload]]
。它抛出这个异常:
java.lang.NullPointerException
at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:112)
at org.mule.component.AbstractComponent.process(AbstractComponent.java:156)
at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:99)
at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:66)
at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:56)
at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:66)
at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:87)
at org.mule.api.processor.MessageProcessors$LifecyleAwareMessageProcessorWrapper.process(MessageProcessors.java:114)
at org.mule.expression.MessageProcessorExpressionEvaluator.evaluate(MessageProcessorExpressionEvaluator.java:87)
at org.mule.expression.DefaultExpressionManager.evaluate(DefaultExpressionManager.java:273)
at org.mule.expression.DefaultExpressionManager.evaluate(DefaultExpressionManager.java:209)
at org.mule.expression.DefaultExpressionManager$1.match(DefaultExpressionManager.java:399)
at org.mule.util.TemplateParser.parse(TemplateParser.java:156)
at org.mule.util.TemplateParser.parse(TemplateParser.java:133)
at org.mule.expression.DefaultExpressionManager.parse(DefaultExpressionManager.java:395)
at org.mule.expression.DefaultExpressionManager.parse(DefaultExpressionManager.java:379)
at org.mule.api.processor.LoggerMessageProcessor.log(LoggerMessageProcessor.java:89)
at org.mule.api.processor.LoggerMessageProcessor.process(LoggerMessageProcessor.java:71)
at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:99)
at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:66)
at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:105)
at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:55)
at org.mule.processor.AsyncInterceptingMessageProcessor.processNextTimed(AsyncInterceptingMessageProcessor.java:111)
at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.doRun(AsyncInterceptingMessageProcessor.java:158)
at org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:43)
at org.mule.work.WorkerContext.run(WorkerContext.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
任何其他脚本组件也会发生同样的情况。我猜它与我的组件生命周期有关,但我找不到让它工作的方法。如果我用任何其他 Mule 处理器(例如 logger、stringAppend)替换我的组件,它就可以正常工作。
任何帮助将不胜感激!