2014-01-06 1 views
0

스프링 JMSTemplate을 사용하여 다른 웹 로직 도메인의 큐에 연결하고 있습니다. jndiTemplate, connectionfactory, destination 등의 모든 구성 요소를 Spring 구성에 연결했습니다. 메시지는 MessageListener의 간단한 구현에 의해 처리됩니다.

모두 정상적으로 작동합니다. 그러나 대상을 사용할 수없는 곳에이 응용 프로그램을 배포하려고하면 배포가 실패합니다. 이것은 우리 환경의 일부에서 JMS 인프라를 사용하지 않아서 매우 중요합니다.
모든 구성 요소에서 lookupOnStartup = false를 시도하고 환경 변수를 기반으로 DMLC에 주입하려고 시도했습니다. 하지만 문제는 듣는 사람이 시작하지 않는 것 같습니다. 모든 메시지는 대기열에 남아 있습니다.테스트 환경에서 JMS 스프링 리스너를 비활성화하는 방법

도움이 매우 감사합니다.

봄 - 구성 :

<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate"> 
    <property name="environment"> 
     <props> 
      <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop> 
      <prop key="java.naming.provider.url">t3://wp2128.xyz.int:7001</prop> 
      <prop key="java.naming.security.authentication">none</prop> 
      <prop key="java.naming.security.principal"></prop> 
      </props>  
    </property> 
</bean> 
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean" > 
    <property name="jndiTemplate" ref="jndiTemplate" /> 
    <property name="jndiName" value="jms/connectionFactory" /> 
</bean> 
<bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean"> 
    <property name="jndiTemplate" ref="jndiTemplate" /> 
    <property name="jndiName" value="jms/testQueue" /> 
</bean> 


<bean id="simpleConsumer" 
    class="org.springframework.jms.listener.DefaultMessageListenerContainer"> 
    <property name="concurrentConsumers" value="5" /> 
    <property name="connectionFactory" ref="connectionFactory" /> 
    <property name="destination" ref="destination" /> 
    <property name="messageListener" ref="simpleMessageListener" /> 
</bean> 
+0

테스트 프로필에서 문제가있는 빈을 제거하기 위해 스프링 프로파일을 사용할 수 있습니다. http://spring.io/blog/2011/02/11/spring-framework-3-1-m1-released/ "콩 정의 프로파일 입력"을 참조하십시오. –

+0

Evgeni가 프로파일을 사용하여 menned 한 것을 참조하는 또 다른 링크가 있습니다. 조건부 시작 : http://stackoverflow.com/questions/8279270/is-there-any-way-to-enable-or-disable-the-spring-bean-definition-in-applicationc –

답변

0

당신은 false로 autoStartup을 설정할 수 있습니다. 이 특성 값은 특성 파일에 구체화 될 수 있습니다.

<bean id="simpleConsumer" 
    class="org.springframework.jms.listener.DefaultMessageListenerContainer"> 
    <property name="concurrentConsumers" value="5" /> 
    <property name="connectionFactory" ref="connectionFactory" /> 
    <property name="destination" ref="destination" /> 
    <property name="messageListener" ref="simpleMessageListener" /> 
    <property name="autoStartup" value="false"/> 
</bean> 
관련 문제