【问题标题】:How to handle endpoint failure in wso2esb and wso2dss如何处理 wso2esb 和 wso2dss 中的端点故障
【发布时间】:2016-08-10 03:42:08
【问题描述】:

我使用 wso2dss 创建了代理服务来插入数据,所以服务运行良好我对此非常满意。但是,当 wso2dss 中发生任何数据重复错误时,我需要在 wso2esb 中处理它,所以我将这个属性保留在 wso2esb 中以用于 dss 级错误句柄:

 <property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/> 

所以它工作正常我得到了 50000 个代码使用这个我能够处理错误而这个错误我的 esb 显示这个消息:

[2014-03-07 11:22:40,778] INFO - LogMediator To: /services/GeoLocationInsertion, MessageID: urn:uuid:b51629e2-934e-4227-8f50-65fd9f719b8e, Direction: request, userid = -1212807836, username = sa|214057357158656, password = sa
[2014-03-07 11:22:40,783] INFO - LogMediator To: /services/ServiceLogin, MessageID: urn:uuid:1967bde1-d820-46f9-957d-55fbb6f7ea9e, Direction: request, usercode = sa, clientid = 214057357158656
[2014-03-07 11:22:40,833] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:24aea5ed-f4e2-4214-809b-b3101031edf7, Direction: response, faisal = true
[2014-03-07 11:22:40,838] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:42a17360-cd04-43bc-83ef-1f53b639de11, Direction: response, kk = true
[2014-03-07 11:22:40,853] WARN - EndpointContext Endpoint : endpoint_71f1485e740c2b97ec407fe4d3bf86929122480f208b6642 will be marked SUSPENDED as it failed
[2014-03-07 11:22:40,853] WARN - EndpointContext Suspending endpoint : endpoint_71f1485e740c2b97ec407fe4d3bf86929122480f208b6642 - last suspend duration was : 30000ms and current suspend duration is : 30000ms - Next retry after : Fri Mar 07 11:23:10 IST 2014
[2014-03-07 11:22:40,856] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:42a17360-cd04-43bc-83ef-1f53b639de11, Direction: response, MESSAGE = Executing default 'fault' sequence, ERROR_CODE = 500000, ERROR_MESSAGE = null
[2014-03-07 11:22:40,857] INFO - LogMediator To: , WSAction: , SOAPAction: , MessageID: urn:uuid:42a17360-cd04-43bc-83ef-1f53b639de11, Direction: response, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ResponseJSON><Body><Data><Exception>duplicate key value violates or The system is attempting to access an inactive service </Exception></Data></Body><Status>500000</Status></ResponseJSON></soapenv:Body></soapenv:Envelope> 

以上错误消息表示我的端点在 30 秒后进入挂起模式,它将自动进入活动模式。

如果任何用户同时尝试,他将无法插入正确的数据,并且由于端点不可用而丢失数据。那么我们如何才能让端点保持在活动模式呢? 如果出现任何其他错误,则不会引发此问题:

[2014-03-07 11:22:40,853] WARN - EndpointContext Suspending endpoint : endpoint_71f1485e740c2b97ec407fe4d3bf86929122480f208b6642 - last suspend duration was : 30000ms and current suspend duration is : 30000ms - Next retry after : Fri Mar 07 11:23:10 IST 2014 

那么我该怎么做呢? 如果我删除该属性,我将无法处理 DSS 级别消息,并且即使我的用户没有得到任何响应,我也会收到这样的错误:

[2014-03-07 11:20:51,816] ERROR - NativeWorkerPool Uncaught exception
java.lang.ClassCastException: org.apache.axiom.om.impl.llom.OMElementImpl cannot be cast to org.apache.axiom.soap.SOAPFault
at org.apache.axiom.soap.impl.llom.SOAPBodyImpl.getFault(SOAPBodyImpl.java:120)
at org.apache.synapse.util.POXUtils.convertSOAPFaultToPOX(POXUtils.java:46)
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:91)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:308)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:92)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:114)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:232)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:443)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:166)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:222)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)

所以 30 秒如此重要,它会导致我的客户的数据丢失。如何避免此端点故障?

wso2dss 中的实际错误是:

Nested Exception:-
org.postgresql.util.PSQLException: ERROR: column "deviceid" is of type bigint but expression is of type character varying
  Hint: You will need to rewrite or cast the expression.
  Position: 81

    at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:105)
    at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.serialize(DSOMDataSource.java:110)
    at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.getReader(DSOMDataSource.java:116)
    at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.getDirectReader(OMSourcedElementImpl.java:225)
    ... 41 more

我在 wso2esb 故障中处理它并且工作正常,但端点故障是无法捕获的

【问题讨论】:

    标签: wso2 wso2esb wso2carbon


    【解决方案1】:

    如果您想在 ESB 中配置 DSS 端点的挂起行为,请参阅Endpoint Error Handling 文档。

    如果您删除 FORCE_ERROR_ON_SOAP_FAULT 属性,您应该仍然能够在 ESB 代理的输出序列中处理来自 DSS 响应的肥皂错误。

    【讨论】:

      【解决方案2】:

      您可以在端点中使用此配置禁用该配置:

      <?xml version="1.0"?>
      <endpoint>
        <address uri="http://localhost:9000/services/SimpleStockQuoteService">
          <timeout>
            <duration>30000</duration>
            <responseAction>fault</responseAction>
          </timeout>
          <suspendOnFailure>
            <errorCodes>-1</errorCodes>
            <initialDuration>0</initialDuration>
            <progressionFactor>1.0</progressionFactor>
            <maximumDuration>0</maximumDuration>
          </suspendOnFailure>
          <markForSuspension>
            <errorCodes>-1</errorCodes>
          </markForSuspension>
        </address>
      </endpoint>
      

      【讨论】:

        【解决方案3】:

        我自己提出了这个错误,很难识别它并找到一种处理它的方法。在处理返回的肥皂故障时,旧版本的 WSO2 ESB 似乎存在错误(我们在 4.8.1 版中遇到了这个问题)。

        您可以查看@JorgeInfanteOsorio 的答案来禁用端点暂停,但您需要解决“未捕获异常”问题。我发现可以从错误消息中检索参数,然后“清除”当前有效负载,因此任何后续调用都不会返回异常问题。

        例子:

        <!--
            After we call a webservice on DSS or other webservice we check if the message contains a fault message
        -->
        <property xmlns:s="http://www.w3.org/2003/05/soap-envelope"
                 name="return_fault"
                 expression="/s:Envelope/s:Body/s:Fault"/>
        
        <filter source="boolean(get-property('return_payzen_fault'))" regex="true">
            <then>
            <!--
                There is a fault message on the payload...
            -->
        
                <!--
                    Retrieve the information from the fault message. How you will access it and which information you will retrieve may be different depending if the answer comes from a third part webservice or from your own DSS.
                -->
                <property xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" name="code" expression="/s:Envelope/s:Body/s:Fault/s:Code/s:faultcode"/>
                <property xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" name="code" expression="/s:Envelope/s:Body/s:Fault/s:Code/s:faultstring"/>
        
                <!--
                     Clear the payload containing the fault message
                  -->
                 <payloadFactory media-type="xml">
                    <format>
                       <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                          <soapenv:Body/>
                       </soapenv:Envelope>
                    </format>
                    <args/>
                 </payloadFactory>
        
                <!--
                     Now you can proceed and process the message as usual without getting the exception. You may probably use the parameters stored in the properties at the beginning to determine which error occured and what you are going to do next.
                -->
        
            </then>
        </filter>
        <!--
            There is no fault message, you can proceed with the message processing here.
        -->
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2015-01-30
          • 1970-01-01
          • 2018-06-09
          • 1970-01-01
          • 2010-09-22
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多