alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
28.02k stars 8.35k forks source link

ClientWorker 一直循环打印日志 #1313

Closed itlidaye closed 4 years ago

itlidaye commented 4 years ago

2020-04-02 15:45:06.070 INFO 7565 --- [bd-aedf53df1e04] c.a.n.client.config.impl.ClientWorker : [fixed-172.16.72.97_8848-bda7516f-d140-4adf-8cbd-aedf53df1e04] [polling-resp] config changed. dataId=api-comm-result.yaml, group=DEFAULT_GROUP, tenant=bda7516f-d140-4adf-8cbd-aedf53df1e04 2020-04-02 15:45:06.270 INFO 7565 --- [bd-aedf53df1e04] c.a.n.client.config.impl.ClientWorker : [fixed-172.16.72.97_8848-bda7516f-d140-4adf-8cbd-aedf53df1e04] [polling-resp] config changed. dataId=api-comm-result.yaml, group=DEFAULT_GROUP, tenant=bda7516f-d140-4adf-8cbd-aedf53df1e04 2020-04-02 15:45:06.271 INFO 7565 --- [bd-aedf53df1e04] c.a.n.client.config.impl.ClientWorker : [fixed-172.16.72.97_8848-bda7516f-d140-4adf-8cbd-aedf53df1e04] [data-received] dataId=api-comm-result.yaml, group=DEFAULT_GROUP, tenant=bda7516f-d140-4adf-8cbd-aedf53df1e04, md5=0a5e535138eb013a700b526f9594e6c9, content=resultmap:

magese commented 4 years ago

+1 配置文件没有进行任何修改,但是持续打印 config changed.日志。 这个情况在第一次启动时会出现,在nacos控制台中修改一次配置文件后就不再循环打印了。


Nothing is changed in the configuration file, but the config changed. log is continuously printed。 This happens the first time you start up, and after you modify the configuration file once in the nacos console, it doesn't print in a loop.

MrLin-619 commented 4 years ago

+1

Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, nacosProperties.getServerAddr());
properties.put(PropertyKeyConst.USERNAME, nacosProperties.getUsername());
properties.put(PropertyKeyConst.PASSWORD, nacosProperties.getPassword());
ConfigService configService = NacosFactory.createConfigService(properties);
String content = configService.getConfig(DATA_ID, "DEFAULT_GROUP", 5000);
log.info("初始化网关路由开始");
updateRoute(content);
log.info("初始化网关路由完成");

//开户监听,实现动态
configService.addListener(DATA_ID, "DEFAULT_GROUP", new Listener() {
    @Override
    public void receiveConfigInfo(String configInfo) {
        log.info("更新网关路由开始");
        updateRoute(configInfo);
        log.info("更新网关路由完成");
    }

    @Override
    public Executor getExecutor() {
        return null;
    }
});
daodao-bot commented 4 years ago

+1

MrLin-619 commented 4 years ago

+1

  • 我也一样,升级到nacos1.2.1+spring-cloud-alibaba2.2.1就出现了这个问题,升级前(2.2.0)是没问题的
  • 代码如下
Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, nacosProperties.getServerAddr());
properties.put(PropertyKeyConst.USERNAME, nacosProperties.getUsername());
properties.put(PropertyKeyConst.PASSWORD, nacosProperties.getPassword());
ConfigService configService = NacosFactory.createConfigService(properties);
String content = configService.getConfig(DATA_ID, "DEFAULT_GROUP", 5000);
log.info("初始化网关路由开始");
updateRoute(content);
log.info("初始化网关路由完成");

//开户监听,实现动态
configService.addListener(DATA_ID, "DEFAULT_GROUP", new Listener() {
  @Override
  public void receiveConfigInfo(String configInfo) {
      log.info("更新网关路由开始");
      updateRoute(configInfo);
      log.info("更新网关路由完成");
  }

  @Override
  public Executor getExecutor() {
      return null;
  }
});
  • 日志如下,控制台一直循环打印
2020-04-16 12:10:52.998  INFO 19692 --- [base-nacos_8848] c.a.n.client.config.impl.ClientWorker    : [fixed-base-nacos_8848] [polling-resp] config changed. dataId=dynamic_routes, group=DEFAULT_GROUP
2020-04-16 12:10:52.998  INFO 19692 --- [base-nacos_8848] c.a.n.client.config.impl.ClientWorker    : get changedGroupKeys:[dynamic_routes+DEFAULT_GROUP]
2020-04-16 12:10:53.021  INFO 19692 --- [base-nacos_8848] c.a.n.client.config.impl.ClientWorker    : [fixed-base-nacos_8848] [data-received] dataId=dynamic_routes, group=DEFAULT_GROUP, tenant=null, md5=07bf53a9f068777b46c7f62b2686fbc8, content=routes:
# auth
...
2020-04-16 12:10:53.998  INFO 19692 --- [base-nacos_8848] c.a.n.client.config.impl.ClientWorker    : [fixed-base-nacos_8848] [polling-resp] config changed. dataId=dynamic_routes, group=DEFAULT_GROUP
2020-04-16 12:10:52.998  INFO 19692 --- [base-nacos_8848] c.a.n.client.config.impl.ClientWorker    : get changedGroupKeys:[dynamic_routes+DEFAULT_GROUP]
2020-04-16 12:10:53.021  INFO 19692 --- [base-nacos_8848] c.a.n.client.config.impl.ClientWorker    : [fixed-base-nacos_8848] [data-received] dataId=dynamic_routes, group=DEFAULT_GROUP, tenant=null, md5=07bf53a9f068777b46c7f62b2686fbc8, content=routes:
# auth
...

把configService.addListener监听的代码注释掉就不报了

在配置文件最后加个空换行就不报了

ghost commented 4 years ago

+1 我也碰到过这个问题

cwh1022 commented 4 years ago

+1 我这边把那个一直config changed那个配置的自动刷新关掉了就好了

i402097836 commented 4 years ago

遇到了同样的问题,求解决 ,无线循环打印

alloevil commented 4 years ago

hi,i get the same problem here is my pom `<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.5.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>xxx</groupId>
<artifactId>xx</artifactId>
<version>develop/v1.x</version>
<name>xx</name>
<description>provide data view</description>
<packaging>jar</packaging>

<properties>
    <java.version>1.8</java.version>
</properties>

<!--    <dependencyManagement>-->
<!--        <dependencies>-->
<!--            &lt;!&ndash; https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-dependencies &ndash;&gt;-->
<!--            &lt;!&ndash;            <dependency>&ndash;&gt;-->
<!--            &lt;!&ndash;                <groupId>org.springframework.cloud</groupId>&ndash;&gt;-->
<!--            &lt;!&ndash;                <artifactId>spring-cloud-dependencies</artifactId>&ndash;&gt;-->
<!--            &lt;!&ndash;                <version>Hoxton.SR4</version>&ndash;&gt;-->
<!--            &lt;!&ndash;                <type>pom</type>&ndash;&gt;-->
<!--            &lt;!&ndash;                <scope>runtime</scope>&ndash;&gt;-->
<!--            &lt;!&ndash;            </dependency>&ndash;&gt;-->

<!--            <dependency>-->
<!--                <groupId>com.alibaba.cloud</groupId>-->
<!--                <artifactId>spring-cloud-alibaba-dependencies</artifactId>-->
<!--                <version>2.2.1.RELEASE</version>-->
<!--                <type>pom</type>-->
<!--                <scope>import</scope>-->
<!--            </dependency>-->
<!--        </dependencies>-->
<!--    </dependencyManagement>-->

<dependencies>
    <dependency>
        <groupId>com.alibaba.cloud</groupId>
        <artifactId>spring-cloud-alibaba-dependencies</artifactId>
        <version>2.2.1.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>Hoxton.SR4</version>
        <type>pom</type>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.10</version>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>29.0-jre</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-collections4</artifactId>
        <version>4.4</version>
    </dependency>
    <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-boot-starter</artifactId>
        <version>3.3.1</version>
    </dependency>

    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.6</version>
    </dependency>

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.9.2</version>
    </dependency>

    <dependency>
        <groupId>com.github.xiaoymin</groupId>
        <artifactId>swagger-bootstrap-ui</artifactId>
        <version>1.9.6</version>
    </dependency>

    <dependency>
        <groupId>org.jasig.cas.client</groupId>
        <artifactId>cas-client-core</artifactId>
        <version>3.3.1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-collections4</artifactId>
        <version>4.4</version>
    </dependency>

    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.2</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-alibaba-nacos-config -->
    <dependency>
        <groupId>com.alibaba.cloud</groupId>
        <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
        <version>2.2.1.RELEASE</version>
        <exclusions>
            <exclusion>
                <groupId>com.alibaba:fastjson</groupId>
                <artifactId>1.2.58</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.alibaba.cloud</groupId>
        <artifactId>spring-cloud-alibaba-dependencies</artifactId>
        <version>2.2.1.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-alibaba-nacos-discovery -->
    <dependency>
        <groupId>com.alibaba.cloud</groupId>
        <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        <version>2.2.1.RELEASE</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
        <version>2.3.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
        <version>1.2.68</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

`

lltx commented 4 years ago

nacos 1.2.1 bug

hejinxu commented 3 years ago

确实,配置文件修改一下就不报了(最后加一个空行)

majingxuan123 commented 2 years ago

修改一下配置文件 加个回车 保存之后就不输出了 应该是bug吧

1239656678 commented 11 months ago

真正的原因是,在新建命名空间的时候没有指定命名空间ID image 而在配置里面配置的确实public导致 正确的应该是配置指定的具体的命名空间id

ros275229 commented 8 months ago

thanks so much!