21.5.3. WS-RM 配置用例
概述
本小节着重介绍从用例的角度配置 WS-RM 属性。其中属性是一个标准的 WS-RM 策略属性(在 http://schemas.xmlsoap.org/ws/2005/02/rm/policy/ 命名空间中定义),只会显示在 rmManager
Spring bean 中的 RMAsertion 中设置它的示例。有关如何在功能内设置这样的属性(如策略)的详情 ; 在 WSDL 文件中或外部附件中,请参阅 第 21.5.2 节 “配置标准 WS-RM 策略属性”。
涵盖以下用例:
基本重新传输间隔
BaseRetransmissionInterval
元素指定在 RM 源重新传输了尚未确认的消息的时间间隔。它在 http://schemas.xmlsoap.org/ws/2005/02/rm/wsrm-policy.xsd 模式文件中定义。默认值为 3000 毫秒。
例 21.8 “设置 WS-RM Base Retransmission Interval” 显示如何设置 WS-RM 基本重新传输间隔。
例 21.8. 设置 WS-RM Base Retransmission Interval
<beans xmlns:wsrm-policy="http://schemas.xmlsoap.org/ws/2005/02/rm/policy ...> <wsrm-mgr:rmManager id="org.apache.cxf.ws.rm.RMManager"> <wsrm-policy:RMAssertion> <wsrm-policy:BaseRetransmissionInterval Milliseconds="4000"/> </wsrm-policy:RMAssertion> </wsrm-mgr:rmManager> </beans>
重新传输的 backoff
ExponentialBackoff
元素确定是否以指数级间隔执行对未确认消息的连续性重新传输尝试。
ExponentialBackoff
元素将启用此功能。默认情况下会使用 2
的 exponential backoff 比例。ExponentialBackoff
是一个标志。当元素存在时,会启用 exponential backoff。当元素不存在时,会禁用 exponential backoff。不需要值。
例 21.9 “设置 WS-RM Exponential Backoff Property” 演示了如何为重新传输设置 WS-RM exponential backoff。
例 21.9. 设置 WS-RM Exponential Backoff Property
<beans xmlns:wsrm-policy="http://schemas.xmlsoap.org/ws/2005/02/rm/policy ...> <wsrm-mgr:rmManager id="org.apache.cxf.ws.rm.RMManager"> <wsrm-policy:RMAssertion> <wsrm-policy:ExponentialBackoff/> </wsrm-policy:RMAssertion> </wsrm-mgr:rmManager> </beans>
确认的时间间隔
AcknowledgementInterval
元素指定 WS-RM 目标发送异步确认的时间间隔。除了同步确认外,还需要接收传入的消息。默认的异步确认间隔为 0
毫秒。这意味着,如果 AcknowledgementInterval
没有配置为特定值,确认将立即发送(即首次可用的商机)。
只有在满足以下条件时,RM 目的地才会发送异步确认:
-
RM 目的地使用非匿名
wsrm:acksTo
端点。 - 在确认间隔到期前不会发生对响应消息的确认机会。
例 21.10 “设置 WS-RM Acknowledgement Interval” 显示如何设置 WS-RM 确认间隔。
例 21.10. 设置 WS-RM Acknowledgement Interval
<beans xmlns:wsrm-policy="http://schemas.xmlsoap.org/ws/2005/02/rm/policy ...> <wsrm-mgr:rmManager id="org.apache.cxf.ws.rm.RMManager"> <wsrm-policy:RMAssertion> <wsrm-policy:AcknowledgementInterval Milliseconds="2000"/> </wsrm-policy:RMAssertion> </wsrm-mgr:rmManager> </beans>
最大未确认的消息阈值
maxUnacknowledged
属性设置在序列被终止前每个序列的最大未确认消息数。
例 21.11 “设置 WS-RM Maximum Unacknowledged Message Threshold” 展示如何设置 WS-RM 的最大消息阈值。
例 21.11. 设置 WS-RM Maximum Unacknowledged Message Threshold
<beans xmlns:wsrm-mgr="http://cxf.apache.org/ws/rm/manager ...> <wsrm-mgr:reliableMessaging> <wsrm-mgr:sourcePolicy> <wsrm-mgr:sequenceTerminationPolicy maxUnacknowledged="20" /> </wsrm-mgr:sourcePolicy> </wsrm-mgr:reliableMessaging> </beans>
RM 序列的最大长度
maxLength
属性设置 WS-RM 序列的最大长度。默认值为 0,
这表示 WS-RM 序列的长度未绑定。
当设置此属性时,RM 端点会在达到限制时创建一个新的 RM 序列,并在收到之前发送的消息的所有确认后。使用 newsequence 发送新消息。
例 21.12 “设置 WS-RM 消息序列的最大长度” 演示了如何设置 RM 序列的最大长度。
例 21.12. 设置 WS-RM 消息序列的最大长度
<beans xmlns:wsrm-mgr="http://cxf.apache.org/ws/rm/manager ...> <wsrm-mgr:reliableMessaging> <wsrm-mgr:sourcePolicy> <wsrm-mgr:sequenceTerminationPolicy maxLength="100" /> </wsrm-mgr:sourcePolicy> </wsrm-mgr:reliableMessaging> </beans>
消息发送保障策略
您可以将 RM 目的地配置为使用以下发送保证策略:
例 21.13 “设置 WS-RM Message Delivery Assurance 策略” 展示如何设置 WS-RM 消息发送保证。
例 21.13. 设置 WS-RM Message Delivery Assurance 策略
<beans xmlns:wsrm-mgr="http://cxf.apache.org/ws/rm/manager ...> <wsrm-mgr:reliableMessaging> <wsrm-mgr:deliveryAssurance> <wsrm-mgr:AtLeastOnce /> </wsrm-mgr:deliveryAssurance> </wsrm-mgr:reliableMessaging> </beans>