2016-07-23 9 views
0

ウェブサービスがダウンしているときだけ、until-successfulを使用してWebサービスを再試行します。Mule 3.7が正常に失敗するまで動作しません。

<until-successful maxRetries="10" failureExpression="#[(message.inboundProperties['http.status'] != 200) &amp;&amp; (message.inboundProperties['http.status'] != 500)]" synchronous="true" millisBetweenRetries="5000"> 

<flow-ref name="callSubFlow" doc:name="Flow Reference"/> 

を私はHTTPレスポンス500を取得する場合、私はまた、Webサービスを呼び出して再試行したくない:以下
は、私がしようとしているものです。私はWebサービスを嘲笑し、HTTP 500応答を返すときに成功するまでWebサービスの呼び出しを再試行し続けます。上記のfailureExpressionの何が問題になっていますか?

ありがとうございました

答えて

0

私の問題が修正された場合の方法はこちらです。私はWebサービス500エラーだけをキャッチする別のフローを作成しました。 until-successfulは、Webサービスを再度呼び出すために再試行しません。

<until-successful maxRetries="${webservice.timeout.max.retries}" failureExpression="#[exception != null &amp;&amp; (exception.causedBy(java.net.ConnectException) || exception.causedBy(java.net.SocketTimeoutException) || exception.causedBy(java.util.concurrent.TimeoutException) || exception.causedBy(java.net.SocketException))]" 
synchronous="true" millisBetweenRetries="5000" > 
<processor-chain doc:name="Processor Chain"> 


     <set-payload value="#[payLoad]" /> 
     <flow-ref name="Flow1" /> 

    </processor-chain> 
</until-successful> 

<flow name="Flow1"> 
<ws:consumer config-ref="WSConsumerConfig" operation="execute" /> 
    <choice-exception-strategy doc:name="Choice Exception Strategy"> 


     <catch-exception-strategy doc:name="Catch Exception Strategy" when="#[exception != null &amp;&amp; exception.causedBy(org.mule.module.ws.consumer.SoapFaultException)]"> 

     <logger message="SoapFaultException occurred." level="INFO" doc:name="Logger"/> 
     <set-payload value="#[exception]" doc:name="Set Payload"></set-payload> 
    </catch-exception-strategy> 

    </choice-exception-strategy> 
</flow> 
1

この表現の周りには多くの混乱があります。ドキュメントごとに、

FAILUREは:「まで、成功した範囲内のメッセージプロセッサが例外をスローしたり、例外ペイロードが含まれている。また、式は属性failureExpressionに設けられ、それが真と評価されている場合。。」

https://docs.mulesoft.com/mule-user-guide/v/3.6/until-successful-scope#success-and-failure

ここでキャッチは、例外がスローさされていない場合ミュール「failureExpression」の現在の実装では、チェックし、使用されているとのことです。それ以外の場合は、例外の場合には常に再試行されます。あなたの問題の解決策は、特定の例外に対してcatchブロックを設定してからプロパティを設定し、failureExpressionでそのプロパティを評価して成功するまで再試行することです。基本的には、再試行のためのコードの再帰技法を使用しています。あなたのコードのための

例:

<until-successful maxRetries="10" failureExpression="#[flowVars['errorInActualOutboundFlow']]" synchronous="true" millisBetweenRetries="5000"> 
    <flow-ref name="callActualOutboundFlow" doc:name="Flow Reference"/> 
</until-successful> 

実際のアウトバウンド・フロー:

<flow name="callActualOutboundFlow" processingStrategy="synchronous">   
    <http:request config-ref="HTTP_Request_Configuration" path="/" method="GET" doc:name="HTTP"/> 
    <choice-exception-strategy doc:name="Choice Exception Strategy"> 
     <catch-exception-strategy doc:name="Catch Exception Strategy" when="#[exception.causedBy(java.net.ConnectException)]"> 
      <logger message="#### Until-Successful will retry in this case " level="INFO" doc:name="Logger"/> 
      <set-variable variableName="errorInActualOutboundFlow" value="#[true]" doc:name="Variable"/> 
     </catch-exception-strategy> 
     <catch-exception-strategy doc:name="Catch Exception Strategy"> 
      <set-variable variableName="errorInActualOutboundFlow" value="#[false]" doc:name="Copy_of_Variable"/> 

0

あなたはまた500が非障害のシナリオであるHTTPリクエストの構成要素を指示する必要がありますこの場合。デフォルトでは200が成功シナリオであるため、「success-status-code-validator」には何も言及する必要はありません。代わりに、直接ここにHTTPを使用しての

<until-successful maxRetries="5" synchronous="true" doc:name="Until Successful" failureExpression="#[ message.inboundProperties['http.status'] != 200 &amp;&amp; message.inboundProperties['http.status'] != 500  ]" millisBetweenRetries="1000"> 
     <http:request config-ref="HTTP_Request_Configuration" path="test1" method="GET" doc:name="HTTP"> 
      <http:success-status-code-validator values="200,500"/>. 
     </http:request> 
</until-successful> 

、成功と<http:success-status-code-validator values="200,500"/>に言及、あなたはHTTP要求を使用どこがcallSubFlowを使用と考えています。したがって、この場合再試行しないで、期待通りに動作します。 500を200以外の別のロジックとして扱う場合は、http:requestの後にmessage.inboundProperties ['http.status']をチェックして条件チェックを行い、200または500に基づいてロジックを進めることができます。

あなたのケースでは、Http-requestが '500'を失敗とし、それまではNon-failureと述べているため、失敗しました。

+0

ご返信ありがとうございます。私は以下のようなWebサービスコンシューマーを使用しています: http:success-status-code-validatorを追加する場所を調べるだけで済みます。 http configは次のとおりです。 max

関連する問題