2016-07-01 2 views
0

스프링 부트 jar를 빌드하는 동안 RabbitMQ가 트리거되거나 실행되는 이유 Application.java 또는 pom.xml을 실행하는 중 RabbitMQ가 트리거되거나 실행되는 이유는 무엇입니까? 스프링 - 부트 비활성화로드 - 온 시작 rabbitMQ

나는 다음과 같은 로거
2016-07-01 16:40:04.334 INFO 7004 --- [   main] com.rabbit.App        : No active profile set, falling back to default profiles: default 
2016-07-01 16:40:04.391 INFO 7004 --- [   main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot[email protected]1da51a35: startup date [Fri Jul 01 16:40:04 CEST 2016]; root of context hierarchy 
2016-07-01 16:40:05.331 INFO 7004 --- [   main] o.s.b.f.s.DefaultListableBeanFactory  : Overriding bean definition for bean 'rabbitListenerContainerFactory' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=rabbitMqConfiguration; factoryMethodName=rabbitListenerContainerFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/rabbit/messaging/configuration/RabbitMqConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=taskConsumerConfiguration; factoryMethodName=rabbitListenerContainerFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/rabbit/messaging/configuration/TaskConsumerConfiguration.class]] 
2016-07-01 16:40:05.334 INFO 7004 --- [   main] o.s.b.f.s.DefaultListableBeanFactory  : Overriding bean definition for bean 'connectionFactory' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=rabbitMqConfiguration; factoryMethodName=connectionFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/rabbit/messaging/configuration/RabbitMqConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=taskConsumerConfiguration; factoryMethodName=connectionFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/rabbit/messaging/configuration/TaskConsumerConfiguration.class]] 
2016-07-01 16:40:05.334 INFO 7004 --- [   main] o.s.b.f.s.DefaultListableBeanFactory  : Overriding bean definition for bean 'jsonMessageConverter' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=rabbitMqConfiguration; factoryMethodName=jsonMessageConverter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/rabbit/messaging/configuration/RabbitMqConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=taskConsumerConfiguration; factoryMethodName=jsonMessageConverter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/rabbit/messaging/configuration/TaskConsumerConfiguration.class]] 
2016-07-01 16:40:05.868 INFO 7004 --- [   main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration' of type [class org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration$$EnhancerBySpringCGLIB$$ad9295b0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
2016-07-01 16:40:06.657 INFO 7004 --- [   main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 

이 비활성화 할 수있는 옵션이 있습니까

을 볼 수 있어요?

테스트 단계에서 jar 파일을 빌드하는 동안 예외가 발생합니다.

LifecycleProcessor with name 'lifecycleProcessor': using default [[email protected]dc36e5] 
2016-06-30 15:10:32.989 WARN 21614 --- [cTaskExecutor-1] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it 

org.springframework.amqp.AmqpIOException: java.net.SocketTimeoutException: connect timed out 
at  org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:67) 
at 
+0

이것은 단지 bean 선언문 일뿐입니다. 정확히 어떤 문제가 있습니까? –

+0

RabbitMQ 호스트 속성은 application.properties에 정의되어 있으며 응용 프로그램을 빌드하는 동안 빌드 스크립트를 사용하여 동적으로 해당 속성을 전달합니다. 테스트 단계에서 항아리를 만드는 동안 아래 예외가 발생합니다. org.springframework.amqp.AmqpIOException : java.net.SocketTimeoutException : connect timed out – VelNaga

+0

jar 파일을 만드는 동안 @Gary Russell Spring 부트가 RabbitMQ 연결을 설정하려고 시도했습니다. 느린 로딩을 통해이를 수행 할 수 있습니까? - Demand on start-up? 또한 @EnableAutoConfiguration (exclude = RabbitAutoConfiguration.class) 주석을 사용해 보았습니다.하지만 luck.atleast SimpleMessageListenerContainer.Layly RabbitMQ connection 또는 SimpleMessageListenerContainer를로드하는 게 가능합니까? – VelNaga

답변

0

해당 이름으로 빈을 두 번 이상 정의하면 '빈 정의 재정의 ..'로그 항목이 표시됩니다.

두 개 이상의 콩 중 어떤 것이 사용되며 어떻게 구성됩니까?

rabbitListenerContainerFactory 빈의 생성자에 중단 점을 설정하고 생성중인 인스턴스를 확인하십시오.

스택 추적을 조회하면이 빈이 작성된 이유에 대한 정보를 얻을 수 있으므로 스프링 구성에서 복제본을 제거 할 수 있습니다.

토끼 연결 속성이 설정된 중단 점을 추가 할 수도 있습니다.

주어진 ip가 잘못된 경우 "connect timed out"도 나타납니다.

어쨌든 응용 프로그램을 시작할 때 빌드 스크립트의 속성을 설정하는 대신 명령 줄의 속성 파일을 가리키는 것은 좋지 않습니다. 따라서 다른 환경에서 빌드를 사용할 수 있습니다. 항아리를 구축하면서 던지고 왜

howto-properties-and-configuration

를 참조하십시오? 작성하는 동안 스크립트로 속성을 설정한다고 썼습니다.

이것은 테스트가 이러한 속성을 사용 중이며 테스트가 실패했음을 의미합니다. 토끼 mq 서버에 제공된 속성으로 연결할 수 없거나 작동하지 않았기 때문일 수 있습니다.

빈을 재정의하는 경우 사용하는 인스턴스를 실제로 알지 못하므로 사용하는 속성을 실제로 알지 못합니다. 로그 아웃하려고 시도합니다.

+0

답장을 보내 주셔서 감사합니다. spring-rabbit.ex) connectionFactory, ListernerContainerFactory에 의해 자동적으로 제공되는 빈은 거의 없다. 내 요구 사항을 기반으로 빈을 수동으로 구성했다. 그래서 정보 메시지가 유효하지만 왜 병을 만드는 동안 왜 던지고 있는가? – VelNaga

0

SmartLifecycle (예 : 청취자 컨테이너)을 구현하는 빈은 컨텍스트에서 Bean을로드해야하기 때문에 "지연로드"할 수 없습니다 빈이 시작되어야하는지 확인하려면 isAutoStartup()을 호출하십시오.

"jar 빌드"중에 컨텍스트를로드하는 경우 bean을 사용하는 테스트 사례가 있어야합니다. autoStartupfalse으로 설정할 수 있지만 테스트가 실패 할 수 있습니다.

-DskipTests=true (maven) 또는 -x test (gradle)으로 테스트 실행을 건너 뛸 수 있습니다.

0

나는 내 테스트에서 동일한 문제가 있습니다. 나는 토끼를 사용하지 않으며 시간 제한이 발생하기 때문에 검사 ​​기간이 길어집니다.

간단한 해결 방법으로 스프링 프로파일을 사용하여 테스트하는 동안 대기열, 교환 등의 구성을 비활성화 할 수 있습니다.

예 :

스프링 프로필 'no_rabbit "가 존재하는 경우 해제되는 구성을 갖는.

@Configuration 
@Profile("!no_rabbit") 
public class RabbitMQConfig { 

    @Bean 
    public Queue queue() { 
     return QueueBuilder.durable("NAMW").withArgument("x-message-ttl", 3600).build(); 
    } 

    // more definitions of bean, exchanges etc. 

} 

그런 다음 테스트에서 단순히 "no_rabbit"프로필을 추가하십시오.

@RunWith(SpringRunner.class) 
@ActiveProfiles({ "no_rabbit" }) 
public class TestClass { 
    ... 
} 

이 접근법의 단점은 토끼를 사용하지 않는 모든 단일 테스트에서 프로필을 추가해야한다는 것입니다. 하지만 제 경우에는 더 나은 해결책이 나올 때까지 괜찮습니다.