Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java spring boot starter集成1.4.3性能下降_Java_Spring_Spring Boot_Spring Integration - Fatal编程技术网

Java spring boot starter集成1.4.3性能下降

Java spring boot starter集成1.4.3性能下降,java,spring,spring-boot,spring-integration,Java,Spring,Spring Boot,Spring Integration,当使用Spring集成将Spring Boot从1.4.2升级到1.4.3时,我注意到性能明显下降 我可以用以下程序重现问题: pom.xml: <?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=

当使用Spring集成将Spring Boot从1.4.2升级到1.4.3时,我注意到性能明显下降

我可以用以下程序重现问题:

pom.xml:

<?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 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>

   <parent>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-parent</artifactId>
       <!--<version>1.4.2.RELEASE</version>-->
       <version>1.4.3.RELEASE</version>
   </parent>

   <artifactId>performance-test</artifactId>
   <version>1.0-SNAPSHOT</version>

   <dependencies>
       <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-integration</artifactId>
       </dependency>
       <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-test</artifactId>
           <scope>test</scope>
       </dependency>
   </dependencies>

</project>
UsersManager.java:

package performance.test;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.messaging.handler.annotation.Payload;

@MessageEndpoint
public class UsersManager {

    private static final Logger LOGGER = LoggerFactory.getLogger(UsersManager.class);

    @ServiceActivator(inputChannel = "testChannel")
    public void process(@Payload String payload) {
        LOGGER.debug("payload: {}", payload);
    }
}
IntegrationTest.java:

package performance.test;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
public class IntegrationTest {

    private static final Logger LOGGER = LoggerFactory.getLogger(IntegrationTest.class);

    @Autowired
    private MessageChannel testChannel;

    @Test
    public void basic_test() {
        for (int i = 1; i <= 10; i++) {
            final long start = System.currentTimeMillis();
            test(1000);
            final long end = System.currentTimeMillis();
            LOGGER.info("test run: {} took: {} msec", i, end - start);
        }
    }

    private void test(int count) {
        for (int i = 0; i < count; i++) {
            testChannel.send(MessageBuilder.withPayload("foo").setHeader("monkey", "do").build());
        }
    }
}
但是,当我使用Spring Boot 1.4.3时,性能会显著下降:

2016-12-27 14:57:41.705  INFO 5122 --- [           main] performance.test.IntegrationTest         : Started IntegrationTest in 1.002 seconds (JVM running for 1.539)
2016-12-27 14:57:41.876  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 1 took: 156 msec
2016-12-27 14:57:42.031  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 2 took: 153 msec
2016-12-27 14:57:42.251  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 3 took: 220 msec
2016-12-27 14:57:42.544  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 4 took: 293 msec
2016-12-27 14:57:42.798  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 5 took: 254 msec
2016-12-27 14:57:43.111  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 6 took: 312 msec
2016-12-27 14:57:43.544  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 7 took: 432 msec
2016-12-27 14:57:44.112  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 8 took: 567 msec
2016-12-27 14:57:44.807  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 9 took: 695 msec
2016-12-27 14:57:45.620  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 10 took: 813 msec
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.989 sec - in performance.test.IntegrationTest
我不知道这是什么原因。 其他人也有同样的问题吗

这可能与


在这种情况下,从消息参数中删除
@Payload
可以解决问题(在这种情况下不需要它-如果有多个参数,您只需要一个Payload注释)。

是的,我们在使用
@Header
注释时注意到了相同的问题。感谢您参考相关的JIRA问题。看起来问题还没有解决。对,我已经打开了一个。
2016-12-27 14:55:39.331  INFO 4939 --- [           main] performance.test.IntegrationTest         : Started IntegrationTest in 0.975 seconds (JVM running for 1.52)
2016-12-27 14:55:39.468  INFO 4939 --- [           main] performance.test.IntegrationTest         : test run: 1 took: 123 msec
2016-12-27 14:55:39.552  INFO 4939 --- [           main] performance.test.IntegrationTest         : test run: 2 took: 83 msec
2016-12-27 14:55:39.632  INFO 4939 --- [           main] performance.test.IntegrationTest         : test run: 3 took: 80 msec
2016-12-27 14:55:39.696  INFO 4939 --- [           main] performance.test.IntegrationTest         : test run: 4 took: 63 msec
2016-12-27 14:55:39.763  INFO 4939 --- [           main] performance.test.IntegrationTest         : test run: 5 took: 67 msec
2016-12-27 14:55:39.842  INFO 4939 --- [           main] performance.test.IntegrationTest         : test run: 6 took: 78 msec
2016-12-27 14:55:39.895  INFO 4939 --- [           main] performance.test.IntegrationTest         : test run: 7 took: 53 msec
2016-12-27 14:55:39.950  INFO 4939 --- [           main] performance.test.IntegrationTest         : test run: 8 took: 55 msec
2016-12-27 14:55:40.004  INFO 4939 --- [           main] performance.test.IntegrationTest         : test run: 9 took: 54 msec
2016-12-27 14:55:40.057  INFO 4939 --- [           main] performance.test.IntegrationTest         : test run: 10 took: 53 msec
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.776 sec - in performance.test.IntegrationTest
2016-12-27 14:57:41.705  INFO 5122 --- [           main] performance.test.IntegrationTest         : Started IntegrationTest in 1.002 seconds (JVM running for 1.539)
2016-12-27 14:57:41.876  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 1 took: 156 msec
2016-12-27 14:57:42.031  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 2 took: 153 msec
2016-12-27 14:57:42.251  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 3 took: 220 msec
2016-12-27 14:57:42.544  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 4 took: 293 msec
2016-12-27 14:57:42.798  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 5 took: 254 msec
2016-12-27 14:57:43.111  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 6 took: 312 msec
2016-12-27 14:57:43.544  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 7 took: 432 msec
2016-12-27 14:57:44.112  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 8 took: 567 msec
2016-12-27 14:57:44.807  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 9 took: 695 msec
2016-12-27 14:57:45.620  INFO 5122 --- [           main] performance.test.IntegrationTest         : test run: 10 took: 813 msec
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.989 sec - in performance.test.IntegrationTest