0

我正在尝试在我的 Mule 流程中实现错误处理逻辑,并且我想测试 HTTP 状态代码。我已经实现了一个消息过滤器,并希望我catch-exception-strategy能捕捉到org.mule.api.routing.filter.FilterUnacceptedException抛出message-property-filter,我可以这样做,但我希望它几乎是嵌套的,但我知道我不能这样做,所以我将我的逻辑语句组合为一个AND操作,像这样:

<catch-exception-strategy when="#[exception.causedBy(org.mule.api.routing.filter.FilterUnacceptedException) &amp;&amp; header:INBOUND:http.status=404]" doc:name="Catch Exception Strategy">

当它被击中时,这如何导致我的流程出错:

[11-03 19:42:33] ERROR CatchMessagingExceptionStrategy [[fault_test].connector.http.mule.default.receiver.02]: 
********************************************************************************
Message               : Message has been rejected by filter. Message payload is of type: ReleasingInputStream
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Message has been rejected by filter. Message payload is of type: ReleasingInputStream (org.mule.api.routing.filter.FilterUnacceptedException)
  org.mule.routing.MessageFilter:100 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/routing/filter/FilterUnacceptedException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.routing.filter.FilterUnacceptedException: Message has been rejected by filter. Message payload is of type: ReleasingInputStream
    at org.mule.routing.MessageFilter.filterUnacceptedException(MessageFilter.java:100)
    at org.mule.processor.AbstractFilteringMessageProcessor.handleUnaccepted(AbstractFilteringMessageProcessor.java:62)
    at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:48)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

[11-03 19:42:33] ERROR CatchMessagingExceptionStrategy [[fault_test].connector.http.mule.default.receiver.02]: Failed to dispatch message to error queue after it failed to process.  This may cause message loss.Logging Message here: 

org.mule.DefaultMuleMessage
{
  id=856cd942-2618-11e2-9e97-f5a070de55a6
  payload=org.mule.transport.http.ReleasingInputStream
  correlationId=<not set>
  correlationGroup=-1
  correlationSeq=-1
  encoding=UTF-8
  exceptionPayload=org.mule.message.DefaultExceptionPayload@e90e23

Message properties:
  INVOCATION scoped properties:
  INBOUND scoped properties:
    Connection=true
    Content-Type=text/xml;charset=UTF-8
    Date=Sat, 03 Nov 2012 07:42:32 CDT
    Keep-Alive=true
    MULE_ENCODING=UTF-8
    MULE_SESSION=rO0ABXNyACNvcmcubXVsZS5zZXNzaW9uLkRlZmF1bHRNdWxlU2Vzc2lvbi7rdtEW7GGKAwAEWgAFdmFsaWRMAA1mbG93Q29uc3RydWN0dAAmTG9yZy9tdWxlL2FwaS9jb25zdHJ1Y3QvRmxvd0NvbnN0cnVjdDtMAAJpZHQAEkxqYXZhL2xhbmcvU3RyaW5nO0wAD3NlY3VyaXR5Q29udGV4dHQAJ0xvcmcvbXVsZS9hcGkvc2VjdXJpdHkvU2VjdXJpdHlDb250ZXh0O3hwAXB0ACQ4NTVjMTA1Yy0yNjE4LTExZTItOWU5Ny1mNWEwNzBkZTU1YTZwc3IAJWphdmEudXRpbC5Db2xsZWN0aW9ucyRTeW5jaHJvbml6ZWRNYXAbc/kJS0s5ewMAAkwAAW10AA9MamF2YS91dGlsL01hcDtMAAVtdXRleHQAEkxqYXZhL2xhbmcvT2JqZWN0O3hwc3IAJG9yZy5tdWxlLnV0aWwuQ2FzZUluc2Vuc2l0aXZlSGFzaE1hcJ3R2e9nRc4AAwAAeHB3DD9AAAAAAAAQAAAAAHhxAH4ACXh4
    Server=Mule EE Core Extensions/3.3.0
    Set-Cookie=[Lorg.apache.commons.httpclient.Cookie;@9f2588
    Transfer-Encoding=chunked
    http.headers={MULE_SESSION=rO0ABXNyACNvcmcubXVsZS5zZXNzaW9uLkRlZmF1bHRNdWxlU2Vzc2lvbi7rdtEW7GGKAwAEWgAFdmFsaWRMAA1mbG93Q29uc3RydWN0dAAmTG9yZy9tdWxlL2FwaS9jb25zdHJ1Y3QvRmxvd0NvbnN0cnVjdDtMAAJpZHQAEkxqYXZhL2xhbmcvU3RyaW5nO0wAD3NlY3VyaXR5Q29udGV4dHQAJ0xvcmcvbXVsZS9hcGkvc2VjdXJpdHkvU2VjdXJpdHlDb250ZXh0O3hwAXB0ACQ4NTVjMTA1Yy0yNjE4LTExZTItOWU5Ny1mNWEwNzBkZTU1YTZwc3IAJWphdmEudXRpbC5Db2xsZWN0aW9ucyRTeW5jaHJvbml6ZWRNYXAbc/kJS0s5ewMAAkwAAW10AA9MamF2YS91dGlsL01hcDtMAAVtdXRleHQAEkxqYXZhL2xhbmcvT2JqZWN0O3hwc3IAJG9yZy5tdWxlLnV0aWwuQ2FzZUluc2Vuc2l0aXZlSGFzaE1hcJ3R2e9nRc4AAwAAeHB3DD9AAAAAAAAQAAAAAHhxAH4ACXh4, Transfer-Encoding=chunked, Date=Sat, 03 Nov 2012 07:42:32 CDT, MULE_ENCODING=UTF-8, Keep-Alive=true, Set-Cookie=[Lorg.apache.commons.httpclient.Cookie;@9f2588, Connection=true, http.status=500, Content-Type=text/xml;charset=UTF-8, Server=Mule EE Core Extensions/3.3.0}
    http.method=POST
    http.query.params={}
    http.query.string=
    http.status=500
    http.version=HTTP/1.1
  OUTBOUND scoped properties:
    MULE_ENCODING=UTF-8
    MULE_SESSION=rO0ABXNyACNvcmcubXVsZS5zZXNzaW9uLkRlZmF1bHRNdWxlU2Vzc2lvbi7rdtEW7GGKAwAEWgAFdmFsaWRMAA1mbG93Q29uc3RydWN0dAAmTG9yZy9tdWxlL2FwaS9jb25zdHJ1Y3QvRmxvd0NvbnN0cnVjdDtMAAJpZHQAEkxqYXZhL2xhbmcvU3RyaW5nO0wAD3NlY3VyaXR5Q29udGV4dHQAJ0xvcmcvbXVsZS9hcGkvc2VjdXJpdHkvU2VjdXJpdHlDb250ZXh0O3hwAXB0ACQ4NTVjMTA1Yy0yNjE4LTExZTItOWU5Ny1mNWEwNzBkZTU1YTZwc3IAJWphdmEudXRpbC5Db2xsZWN0aW9ucyRTeW5jaHJvbml6ZWRNYXAbc/kJS0s5ewMAAkwAAW10AA9MamF2YS91dGlsL01hcDtMAAVtdXRleHQAEkxqYXZhL2xhbmcvT2JqZWN0O3hwc3IAJG9yZy5tdWxlLnV0aWwuQ2FzZUluc2Vuc2l0aXZlSGFzaE1hcJ3R2e9nRc4AAwAAeHB3DD9AAAAAAAAQAAAAAHhxAH4ACXh4
  SESSION scoped properties:
}
org.mule.api.MessagingException: [Error: was expecting type: java.lang.Boolean; but found type: java.util.Map]
[Near : {... eader:INBOUND:http.status=404 ....}]
                                          ^
[Line: 1, Column: 110] (org.mule.api.expression.InvalidExpressionException). Message payload is of type: ReleasingInputStream
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:35)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:43)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:43)
    at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:93)
    at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:66)
    at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:57)
    at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:66)
    at org.mule.processor.chain.InterceptingChainLifecycleWrapper.access$001(InterceptingChainLifecycleWrapper.java:29)
    at org.mule.processor.chain.InterceptingChainLifecycleWrapper$1.process(InterceptingChainLifecycleWrapper.java:90)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:43)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:43)
    at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:85)
    at org.mule.exception.TemplateMessagingExceptionStrategy.route(TemplateMessagingExceptionStrategy.java:136)
    at org.mule.exception.TemplateMessagingExceptionStrategy.handleException(TemplateMessagingExceptionStrategy.java:46)
    at org.mule.exception.ChoiceMessagingExceptionStrategy.handleException(ChoiceMessagingExceptionStrategy.java:44)
    at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:45)
    at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:18)
    at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:58)
    at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:48)
    at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:54)
    at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:44)
    at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:44)
    at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:52)
    at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:32)
    at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:17)
    at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:113)
    at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:34)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.doRequest(HttpMessageReceiver.java:305)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.processRequest(HttpMessageReceiver.java:251)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:163)
    at org.mule.work.WorkerContext.run(WorkerContext.java:311)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.mule.api.expression.InvalidExpressionException: [Error: was expecting type: java.lang.Boolean; but found type: java.util.Map]
[Near : {... eader:INBOUND:http.status=404 ....}]
                                          ^
[Line: 1, Column: 110]
    at org.mule.el.mvel.MVELExpressionLanguage.validate(MVELExpressionLanguage.java:244)
    at org.mule.el.mvel.MVELExpressionLanguage.evaluateInternal(MVELExpressionLanguage.java:195)
    at org.mule.el.mvel.MVELExpressionLanguage.evaluate(MVELExpressionLanguage.java:169)
    at org.mule.expression.DefaultExpressionManager.evaluate(DefaultExpressionManager.java:234)
    at org.mule.expression.DefaultExpressionManager.evaluateBoolean(DefaultExpressionManager.java:361)
    at org.mule.routing.filters.ExpressionFilter.accept(ExpressionFilter.java:127)
    at org.mule.routing.ChoiceRouter.selectProcessors(ChoiceRouter.java:35)
    at org.mule.routing.AbstractSelectiveRouter.process(AbstractSelectiveRouter.java:194)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
    ... 34 more

有没有办法在 Mule 中实现这种类型的逻辑?

4

1 回答 1

3

问题是您正在混合表达式评估器。您的 when 子句应如下所示:

<catch-exception-strategy when="#[exception.causedBy(org.mule.api.routing.filter.FilterUnacceptedException) and message.inboundProperties['http.status']=404 ]" doc:name="Catch Exception Strategy">

在这里您可以找到有关MEL的文档

于 2012-11-04T18:43:54.503 回答