目前,我有一个流程公开 REST 服务,并以字符串作为输入参数。我使用正则表达式过滤器来确保格式参数如下:
<http:inbound-endpoint doc:name="HTTP"
connector-ref="ciuServiceHTTPConnector" ref="ciuServiceHTTPEndpoint"
exchange-pattern="request-response" />
<logger level="INFO" doc:name="Logger" message="epale1 #[payload]"/>
<regex-filter pattern="^/api/person/(V|E)[0-9]{8}$"
doc:name="Regex" />
<logger message="epale2 #[payload]" level="INFO" doc:name="Logger"/>
<jersey:resources doc:name="REST" >
<component class="...resource.CiudadanoResource"/>
</jersey:resources>
我需要向客户发送消息“参数无效或丢失”。为此,我使用 choice-exception-strategy 和 catch-exception-strategy,然后调用 Subflow 并执行 http:response-builder。
当正则表达式过滤器不匹配时,如何抛出异常(类型)?可以合并这种行为还是我应该改变我的流程?
感谢您的帮助;
最佳答案
将其包装在消息过滤器中,如下所示:
<message-filter throwOnUnaccepted="true">
<regex-filter pattern="^/api/person/(V|E)[0-9]{8}$"
doc:name="Regex" />
</message-filter>
请参阅official documentation欲了解更多详情:
Check the Throw On Unaccepted box to throw an exception if a message or event is not handled. The default when not checked is to not throw an exception.
关于mule - 如何使用 Mule ESB 中的 regex-filter 过滤器捕获异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23363862/