spring-cloud-starter-hystrix 和 spring-cloud-starter-archaius 集成的内存泄漏问题 [英] Memory Leak Issue with spring-cloud-starter-hystrix and spring-cloud-starter-archaius integration

查看:93
本文介绍了spring-cloud-starter-hystrix 和 spring-cloud-starter-archaius 集成的内存泄漏问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将 spring-cloud-starter-hystrix 与 spring-cloud-starter-archaius 一起使用,一旦战争取消部署,我们将无法停止 archaius 的 poolingconfigurationSource 线程.但是 spring-cloud-starter-archaius 在没有 hystrix 的情况下工作正常,一旦战争取消部署,线程就会停止.

We are using spring-cloud-starter-hystrix with spring-cloud-starter-archaius where we are unable to stop the poolingconfigurationSource thread of archaius once the war is un-deployed. But spring-cloud-starter-archaius is working fine without hystrix and thread is stopped once war is un-deployed.

推荐答案

**Issue resolved permanently.**

**There are 2 approach :**
1) Create ContextListener in Servlet and in destroy method , copy below code.

2) If you are using Histrix + Spring Boot + Archaius then on main spring application java file , copy below code in method annonated with @PreDestory annotations.

    **Solution :**

    try {
    if (ConfigurationManager.getConfigInstance() instanceof DynamicConfiguration) {
    DynamicConfiguration config = (DynamicConfiguration) ConfigurationManager.getConfigInstance();
    config.stopLoading();
    } else if (ConfigurationManager.getConfigInstance() instanceof ConcurrentCompositeConfiguration) {
    ConcurrentCompositeConfiguration configInst = (ConcurrentCompositeConfiguration) ConfigurationManager
    .getConfigInstance();
    List<AbstractConfiguration> configs = configInst.getConfigurations();
    if (configs != null) {
    for (AbstractConfiguration config : configs) {
    if (config instanceof DynamicConfiguration) {
    ((DynamicConfiguration) config).stopLoading();
    break;
    }
    }
    }
    }
    } catch (Exception e) {
    e.printStackTrace();
    } 

这篇关于spring-cloud-starter-hystrix 和 spring-cloud-starter-archaius 集成的内存泄漏问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆