wso2 - 呼叫调解器超时后继续序列调解
问题描述
端点可以有三种超时配置。永远不要超时、丢弃或出错。我迫切需要在超时后继续流程。有没有办法做到这一点?故障处理程序(onError 序列)不是此问题的理想解决方案。想象一下有八个呼叫中介的编排,我必须创建八个序列并将彼此设置为故障。这将很快使碳应用程序膨胀,使代码不可读并增加部署时间。
解决方案
基本上,在任何给定时间,端点的状态都可以是以下之一。
- 积极的
- 暂停
- 暂停
- 离开
当端点处于“超时”状态时,它将继续尝试接收消息,直到一条消息成功或达到最大重试设置。如果达到最大值,则端点被标记为“暂停”。如果一条消息成功,则端点被标记为“活动”。
如果您需要根据端点超时配置在获得端点超时时继续中介流,您可以使用 responseAction 中的故障选项。
然后,只要端点超时,就会触发故障序列(如果您已经定义了自定义故障序列,否则使用默认故障序列)。如果您需要继续调解流程并且根据现有实现,您可以在自定义序列中定义所需的调解逻辑,并在故障序列中调用该序列,如下所示。
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="customFaultSequence" xmlns="http://ws.apache.org/ns/synapse">
<!-- Log the message at the full log level with the ERROR_MESSAGE and the ERROR_CODE-->
<log level="full">
<property name="MESSAGE" value="Executing default 'fault' sequence"/>
<property expression="get-property('ERROR_CODE')" name="ERROR_CODE" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="get-property('ERROR_MESSAGE')" name="ERROR_MESSAGE" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
<sequence key="afterTimeoutEndpointSequence"/>
</sequence>
示例代理服务:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestProxy" startOnLoad="true" statistics="disable" trace="disable" transports="http,https">
<target faultSequence="customFaultSequence">
<inSequence>
<endpoint>
<address uri="http://run.mocky.io/v3/51c11e65-55a7-47e5-ba38-1d86e8e5d7ea?mocky-delay=45000ms">
<timeout>
<duration>2</duration>
<responseAction>fault</responseAction>
</timeout>
</address>
</endpoint>
<respond/>
</inSequence>
<description/>
</proxy>
推荐阅读
- html - 导入文件中的法语字符在 IE 中未正确显示
- java - 为什么 gc 日志文件中的 Metaspace 大小大于 MaxMetaspaceSize 参数
- graph-databases - 带有顶点列表的 GroupBy 查询
- c# - 如何使鼠标右键单击以自动射击,如果再次单击鼠标左键,每次鼠标左键单击都会射击一次?
- ios - Notifications.getExpoPushTokenAsync 在独立 iOS 上不起作用
- laravel - 如何访问公用文件夹外的js文件?
- python - 如何将图片从 QListview 添加到 QGraphicsView?(使用拖放)
- google-cloud-firestore - 允许用户使用 Firestore 安全规则更新他自己的文档(但不是角色)
- openssl - 为 localhost 设置 ssl wo 一个域
- reactjs - 如何修复 Typescript 中的“对象”类型上不存在“属性“字符串”错误