直到成功的失败表达式都将检查多种类型的异常 [英] Until successful failure expression that checks for multiple types of exceptions

查看:73
本文介绍了直到成功的失败表达式都将检查多种类型的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Mule中,我正在HTTP端点周围使用直到成功,以捕获连接异常/超时.我捕获了3种不同的Java异常:

In Mule, I'm using an until successful around an HTTP endpoint, to catch connection exceptions/timeouts. I'm catching 3 different Java exceptions:

  • java.net.ConnectException
  • java.net.SocketTimeoutException
  • java.net.SocketException

我想将这3个捕获到我的until-successful块中的failureExpression中,但是当我尝试做类似

I want to put the catching of these 3 into a failureExpression in my until-successful block, however when I try to do something like

  • #[exception-type:XYZ || exception-type:ZYX]
  • #[exception-type:XYZ] || #[exception-type:ZYX]
  • #[exception-type:XYZ || exception-type:ZYX]
  • #[exception-type:XYZ] || #[exception-type:ZYX]

我收到一个错误,它无法解析这些错误.有什么方法可以指定failureExpression来检查多种异常类型吗?

I get an error that it cannot parse these. Is there any way I can specify for the failureExpression to check for multiple exception types?

推荐答案

使用此功能,我可以实现自己想要的功能:

I was able to achieve what I wanted using this:

failureExpression="#[exception != null && (exception.causedBy(java.net.ConnectException) || exception.causedBy(java.net.SocketTimeoutException) || exception.causedBy(java.net.SocketException))]"

我的问题是失败表达式中的exception可能是null,因此我必须执行空检查.

My problem was the exception in the failure expression could be null, so I had to perform a null check.

这篇关于直到成功的失败表达式都将检查多种类型的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆