2016-12-27 18 views
2

スプリング統合を使用しているときに、Spring-Bootを1.4.2から1.4.3にアップグレードすると、パフォーマンスが大幅に低下することに気付きました。私は、次のプログラムに問題を再現することができspring-boot-starter-integration 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> 

Application.java:

package performance.test; 

import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 

@SpringBootApplication 
public class Application { 

    public static void main(final String[] args) { 
     SpringApplication.run(Application.class, args); 
    } 
} 

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); 
    } 
} 

インテグレーションTest.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()); 
     } 
    } 
} 

私は春ブーツ1.4.2を使用する場合、私は次のような結果を得る:私は春ブーツ1.4.3を使用する場合しかし

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 

私はこれの原因が分かりません。 他の人に同じ問題がありますか?

答えて

3

これはSPR-14929に関連している可能性があります。

この場合、メッセージパラメータから@Payloadを削除すると、この問題は解決されます(この場合、複数のパラメータがある場合はペイロードアノテーションのみ必要です)。

+0

はい、私は '@ Header'アノテーションを使用したときに同じ問題が発生していることに気付きました。 –

+0

関連するJIRAの問題を参照してくれてありがとう。 問題はまだ解決されていないようです。 –

+0

右 - [新しいJIRAの問題](https://jira.spring.io/browse/SPR-15060)を開いています。 –

関連する問題