gpt4 book ai didi

Mule 请求回复和回滚异常策略

转载 作者:行者123 更新时间:2023-12-01 12:31:37 27 4
gpt4 key购买 nike

我有一个骡子流,我在其中配置了请求回复范围。流程如下:

<flow name="RequestReplyFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/test" doc:name="HTTP" />
<set-payload value="#['Sample Payload']" doc:name="Set Payload" />
<request-reply doc:name="Request-Reply">
<vm:outbound-endpoint exchange-pattern="one-way" path="request" doc:name="VM" />
<vm:inbound-endpoint exchange-pattern="one-way" path="reply" doc:name="VM" />
</request-reply>
</flow>

<flow name="RequestReplyFlow1">
<vm:inbound-endpoint exchange-pattern="one-way" path="request" doc:name="VM" />
<logger message="Executing with payload: #[payload]" level="INFO" doc:name="Logger" />
<component class="org.ram.BusinessComponent" doc:name="Java" />
<rollback-exception-strategy maxRedeliveryAttempts="5" doc:name="Rollback Exception Strategy">
<logger message="Will attempt redelivery" level="INFO" doc:name="Logger" />
</rollback-exception-strategy>
</flow>

我在 request VM 入站端点上配置了 rollback-exception-strategy

当组件 org.ram.BusinessComponent 抛出异常时,我期望的是消息被重新传送到入站 VM 端点,但它并没有发生。为什么?

谁能解决这个问题?

最佳答案

如果您使用回滚异常策略而不是 unhandled exceptions 的默认异常策略,那么你只需要在“rollback-exception-strategy”中通过添加“vm:outbound-endpoint”和“reply”路径来手动指定重定向,请注意 maxRedeliveryAttempts 已更改为“0”,因为你的 vm 是非事务性:

<flow name="RequestReplyFlow1">
<vm:inbound-endpoint exchange-pattern="one-way" path="request" doc:name="VM" />
<logger message="Executing with payload: #[payload]" level="INFO" doc:name="Logger" />
<component class="org.ram.BusinessComponent" doc:name="Java" />
<rollback-exception-strategy maxRedeliveryAttempts="0" doc:name="Rollback Exception Strategy">
<logger message="Will attempt redelivery" level="INFO" doc:name="Logger" />
<vm:outbound-endpoint exchange-pattern="one-way" path="reply" doc:name="VM" />
</rollback-exception-strategy>
</flow>

当虚拟机为 transactional 时那么值 maxRedeliveryAttempts=5 是有意义的,因为在这种情况下 Mule 会尝试重新传递消息五 (5) 次。然后,您可以通过在“on-redelivery-attempts-exceeded”子元素中添加“vm:outbound-endpoint”和“reply”路径,在“rollback-exception-strategy”中手动指定重定向:

<flow name="RequestReplyFlow1">
<vm:inbound-endpoint exchange-pattern="one-way" path="request" doc:name="VM" />
<logger message="Executing with payload: #[payload]" level="INFO" doc:name="Logger" />
<component class="org.ram.BusinessComponent" doc:name="Java" />
<rollback-exception-strategy maxRedeliveryAttempts="0" doc:name="Rollback Exception Strategy">
<logger message="Will attempt redelivery" level="INFO" doc:name="Logger" />
<on-redelivery-attempts-exceeded>
<logger message="redelivery attempt exceeded" level="INFO" doc:name="Logger" />
<vm:outbound-endpoint exchange-pattern="one-way" path="reply" doc:name="VM" />
</on-redelivery-attempts-exceeded>
</rollback-exception-strategy>
</flow>

关于Mule 请求回复和回滚异常策略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33770617/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com