使用MuleMessage参数从MEL调用spring bean

时间:2016-02-02 05:18:32

标签: java spring mule

我正在寻找一种从Mule的MEL中调用spring bean的方法,并传入MuleMessage。

我特意在寻找消息的exceptionPayload属性,因为我是从选择异常处理程序调用的。我尝试过像这样调用bean:

    <choice-exception-strategy doc:name="Choice Exception Strategy">
        <catch-exception-strategy when="#[app.registry.myBean.aMethod(message)]" doc:name="Choice 1">
            <set-payload value="blah" doc:name="Set Payload"/>
        </catch-exception-strategy>
    </choice-exception-strategy>

...但是,传递的参数是org.mule.el.context.MessageContext,它无法访问消息或任何异常属性。

1 个答案:

答案 0 :(得分:0)

如果您不介意将自己绑定到Mule API,这不是一个真正的问题,因为您仍然想要使用Mule细节。我要写一个实现https://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/processor/MessageProcessor.html

的自定义消息处理器

或实施Callable:https://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/lifecycle/Callable.html

两者都允许您深入了解消息。

或者将spring bean非mule特定,只需将异常和变量分别传递给方法。