我正在尝试配置WSO2以从ActiveMQ消费消息,并在处理过程中发生错误时重新排队,通常是远程Web服务调用失败时。
<proxy name="SimpleStockQuoteService" transports="jms" startOnLoad="true">
<target>
<inSequence onError="JSMErrorHandling">
<log level="full"/>
<send>
<endpoint>
<address uri="http://localhost/testapp"/>
</endpoint>
</send>
<log level="full"/>
<log level="custom">
<property name="Custom log" value="End In Sequence"/>
</log>
</inSequence>
<outSequence>
...
</outSequence>
</target>
</proxy>
<sequence name="JSMErrorHandling">
<log level="custom">
<property name="Error" value="Error executing sequence"/>
</log>
<property name="SET_ROLLBACK_ONLY" value="true" scope="axis2"/>
<drop/>
</sequence>
在axis2.xml中,使用transport.jms.SessionTransacted属性将Activemq配置为true。
当远程URL格式无效(例如使用错误的协议)时,JMS回滚/重传/[重定向到死信]功能按预期工作。 但是,如果我停止远程Web服务器或使用无效的服务器名称,则消息不会重新排队,尽管JMSErrorHandling序列处理了错误。
以下是日志摘录:
[2013-06-04 12:17:47,810] INFO - LogMediator To: , WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: ID:GCHESNEL764-57101-1370344525419-9:1:1:1:1, Direction: request, Envelope: <?xml ver
[2013-06-04 12:17:47,813] INFO - LogMediator To: , WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: ID:GCHESNEL764-57101-1370344525419-9:1:1:1:1, Direction: request, Envelope: <?xml ver
[2013-06-04 12:17:47,814] INFO - LogMediator Custom log = End In Sequence
[2013-06-04 12:17:48,818] WARN - ConnectCallback Connection refused or failed for : localhost/127.0.0.1:80
[2013-06-04 12:17:48,821] WARN - EndpointContext Endpoint : endpoint_413907dd1d4e2370ea0ae277fbfebcaf6504f196a11459bb will be marked SUSPENDED as it failed
[2013-06-04 12:17:48,823] WARN - EndpointContext Suspending endpoint : endpoint_413907dd1d4e2370ea0ae277fbfebcaf6504f196a11459bb - current suspend duration is : 30000ms - Next retry after : Tue J
[2013-06-04 12:17:48,824] INFO - LogMediator Error = Error executing sequence
似乎WSO2正在异步调用HTTP并在请求失败前提交JMS事务。是否能够配置此行为?
如果需要进一步处理 - 即链接远程服务调用 - 如何确保JMS事务在输出序列中保持打开状态,以便在后续阶段出现错误时可以回滚?
最后,如果WSO2服务在处理过程中关闭,则该消息不会重新排队。这里提供的配置有其他替代方案吗:http://docs.wso2.org/wiki/display/ESB460/JMS+FAQ#JMSFAQ-Howtopreventmessagelossduetounavailabilityofadatasource Guillaume