mule - 如何使用 Mule ESB 中的 regex-filter 过滤器捕获异常

标签 mule mule-studio

目前,我有一个流程公开 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/

相关文章:

mule-studio - 如何在 Mule Studio 中配置 Mule 属性编辑器

json - 消费 org.glassfish.grizzly.utils.BufferInputStream@ Mule

java - 如何在 mule 中获取调用属性的值?

mule - 请求-回复范围与请求-响应交换模式

mule 从元素文件 :inbound-endpoint 开始发现无效内容

Mule - 从 Jersey Component 流返回

mule - 如何在 Data weaver : Mule 中检查空条件

mysql - 功能未实现查询 : select * from alarm_status Parameters: []

java - Mule 流中的 Groovy 脚本不起作用

sockets - ule子上的AMQPConnector-SocketException : Too many open files