私は時々503エラーを返すhttpゲートウェイ呼び出しを持っています。私はその呼び出しの周りにretry adviceを設定したいと思いますが、私は503だけのすべてのエラーに対してそれをしたくありません。Spring統合メッセージフローの条件付き再試行アドバイス?
<int-http:outbound-gateway ... errorHandler="...">
<int-http:request-handler-advice-chain>
<int:retry-advice max-attempts="3" />
</int-http:request-handler-advice-chain>
</int-http:outbound-gateway>
私はすでにカスタムエラーハンドラがステータス(例:404)をフィルタリングその設定されている、私はエラーとして扱いする必要はありませんが、私はアドバイスが適用される方法を制御するために明白な方法が表示されません私がエラーハンドラでできることに基づいています。 This questionは同じ問題を扱いますが、答えにはアドバイスの動作を制御する方法や、エラーハンドラレベルで要求を再発行する方法は説明されていません。スローする特定の例外タイプはありますか?
編集:答えに基づい例:
<bean id="spelParser" class="org.springframework.expression.spel.standard.SpelExpressionParser" />
<int-http:outbound-gateway ...>
<int-http:request-handler-advice-chain>
<bean class="org.springframework.integration.handler.advice.RequestHandlerRetryAdvice">
<property name="retryTemplate">
<bean class="org.springframework.retry.support.RetryTemplate">
<property name="retryPolicy">
<bean class="org.springframework.retry.policy.ExpressionRetryPolicy">
<constructor-arg index="0" type="org.springframework.expression.Expression" value="#{spelParser.parseExpression('cause.statusCode.value() == 503')}" />
<property name="maxAttempts" value="3" />
</bean>
</property>
<property name="backOffPolicy">
<bean class="org.springframework.retry.backoff.ExponentialBackOffPolicy">
<property name="initialInterval" value="1000" />
<property name="multiplier" value="2" />
</bean>
</property>
</bean>
</property>
</bean>
</int-http:request-handler-advice-chain>
</int-http:outbound-gateway>
ポリシーをカスタマイズするには、カスタムポリシーでカスタム 'RetryTemplate'を注入して、' '(' RequestHandlerRetryAdvice')としてアドバイスを提供します。 –
私はExpressionRetryPolicyをワイヤリングする方法を見ていると思います。 (私はその依存関係を別々に取得する必要がありました。なぜなら、春の統合:4.3.12.RELEASEは、そのクラスが導入された新しいバージョン1.2ではなく、Springリトライ:1.1.xのみを取得します)。しかし、これは式を解決できないためです。 ( 'EL1008E: 'org.springframework.beans.factory.config.BeanExpressionContext'の型のオブジェクトで '$ statusCode'というプロパティまたはフィールドが見つかりませんでした。おそらくpublicではないでしょうか?)私が試みたSPELは' expression = "#{$ statusCode.value()== 503} "' –
???それはSpELではありません。ランタイム表現を指定する必要があります。そして私はすでにあなたに言った: 'expression =" statusCode.value()== 503 "'。あなたがしようとしているのは、 'bean factory initialization expression'と呼ばれますが、実際には実行時ではありません。とにかく '$'シンボルも間違っています... –