ゲートウェイアクセスのタイムアウトは504を返します

問題を整理

[現象]アクセスゲートウェイタイムアウト
{
    "timestamp": "2019-06-29 11:45:13",
    "path": "/admin/user/info",
    "status": 504,
    "error": "Gateway Timeout",
    "message": "Response took longer than configured timeout"
}
[方法]ソースコードのエラー位置を表示するためによれば、

AbstractCommand->

HystrixObservableTimeoutOperator->

最後のリファレンス TL = HystrixTimer.getInstance()addTimerListener(リスナー)。

  1. 時間のリスニングクラスを参照してください。
public Reference<TimerListener> addTimerListener(final TimerListener listener) {
        startThreadIfNeeded();
        // add the listener

        Runnable r = new Runnable() {

            @Override
            public void run() {
                try {
                    listener.tick();
                } catch (Exception e) {
                    logger.error("Failed while ticking TimerListener", e);
                }
            }
        };

        ScheduledFuture<?> f = executor.get().getThreadPool().scheduleAtFixedRate(r, listener.getIntervalTimeInMilliseconds(), listener.getIntervalTimeInMilliseconds(), TimeUnit.MILLISECONDS);
        return new TimerReference(listener, f);
    }

2.キーポイントを探します

    listener.getIntervalTimeInMilliseconds()

3.次に実現リスタを見て

        @Override
        public int getIntervalTimeInMilliseconds() {
            return properties.timerDelayInMilliseconds().get();
        }

4.プロパティキークラスを探します

HystrixCollapserProperties

5.最後にキー属性を見つけました

timerDelayInMilliseconds

 protected HystrixCollapserProperties(HystrixCollapserKey key, Setter builder, String propertyPrefix) {
        this.maxRequestsInBatch = getProperty(propertyPrefix, key, "maxRequestsInBatch", builder.getMaxRequestsInBatch(), default_maxRequestsInBatch);
        this.timerDelayInMilliseconds = getProperty(propertyPrefix, key, "timerDelayInMilliseconds", builder.getTimerDelayInMilliseconds(), default_timerDelayInMilliseconds);
        this.requestCacheEnabled = getProperty(propertyPrefix, key, "requestCache.enabled", builder.getRequestCacheEnabled(), default_requestCacheEnabled);
        this.metricsRollingStatisticalWindowInMilliseconds = getProperty(propertyPrefix, key, "metrics.rollingStats.timeInMilliseconds", builder.getMetricsRollingStatisticalWindowInMilliseconds(), default_metricsRollingStatisticalWindow);
        this.metricsRollingStatisticalWindowBuckets = getProperty(propertyPrefix, key, "metrics.rollingStats.numBuckets", builder.getMetricsRollingStatisticalWindowBuckets(), default_metricsRollingStatisticalWindowBuckets);
        this.metricsRollingPercentileEnabled = getProperty(propertyPrefix, key, "metrics.rollingPercentile.enabled", builder.getMetricsRollingPercentileEnabled(), default_metricsRollingPercentileEnabled);
        this.metricsRollingPercentileWindowInMilliseconds = getProperty(propertyPrefix, key, "metrics.rollingPercentile.timeInMilliseconds", builder.getMetricsRollingPercentileWindowInMilliseconds(), default_metricsRollingPercentileWindow);
        this.metricsRollingPercentileWindowBuckets = getProperty(propertyPrefix, key, "metrics.rollingPercentile.numBuckets", builder.getMetricsRollingPercentileWindowBuckets(), default_metricsRollingPercentileWindowBuckets);
        this.metricsRollingPercentileBucketSize = getProperty(propertyPrefix, key, "metrics.rollingPercentile.bucketSize", builder.getMetricsRollingPercentileBucketSize(), default_metricsRollingPercentileBucketSize);
    }

ORZ Hystrixを通じてゲートウェイタイムアウト属性制御

間違った方向、かつ迅速に方向を変え

https://www.cnblogs.com/520playboy/p/8074347.html

概要

ゲートウェイは、プロパティを探して、そして長い時間のために試みられている、最終的には間違った方向で見つかったソースコード、および調整方向を見ることで、すべての種類を見つけるためにビンゴをインターネットを見つけられませんでした。

おすすめ

転載: www.cnblogs.com/mengjianzhou/p/11106221.html