2014-09-27 18 views
0

jms 및 hornetq을 공급자로 사용하여 상호 작용을 추가하기로 한 프로젝트에서 작업 중입니다.
나는 카멜에게 아주 익숙하다. 그래서 사소한 언급을해도 문제가 생겼다.
목표는 연결 팩토리를 초기화하고 jms 구성 요소를 추가하는 것이 었습니다. 그러나, 내가 알고 있듯이 경로 구성자에서 직접 수행 할 수는 없습니다. 그래서 camel-config.xml을 만들어서 resources/디렉토리에 저장했습니다.
나는 다음과 같은 방법으로 그것을 작성 : 그것은 봄을 사용하지 않는 내가 발견 한 XML의 유일한 예였다 있도록스키마가있는 구성 요소가 없습니다. jms

<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:camel="http://camel.apache.org/schema/spring" 
     xsi:schemaLocation=" 
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
      http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> 

    <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate"> 
     <property name="environment"> 
      <props> 
       <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop> 
       <prop key="java.naming.provider.url">jnp://localhost:1099</prop> 
       <prop key="java.naming.factory.url.pkgs">org.jnp.interfaces:org.jboss.naming</prop> 
      </props> 
     </property> 
    </bean> 

    <bean id="jmsQueueConnectionFactory" 
      class="org.springframework.jndi.JndiObjectFactoryBean"> 
     <property name="jndiTemplate"> 
      <ref bean="jndiTemplate"/> 
     </property> 
     <property name="jndiName"> 
      <value>ConnectionFactory</value> 
     </property> 
    </bean> 

    <bean name="jms" class="org.apache.camel.component.jms.JmsComponent"> 
     <property name="connectionFactory" ref="jmsQueueConnectionFactory"/> 
    </bean> 

</beans> 

이 프로젝트는 스프링을 사용하지 않습니다. 나는 그것이 FailedToCreateEndpointException을 던져
"JMS 스키마를 찾을 수 없음 구성 요소"를 언급하지 않는 프로젝트를 시작할 때 경로 구성 프로그램에서 나는, 그러나

routeBuilder.from("jms:queue:top").to("...");를 사용합니다.
xml 파일이 단순히 사용되지는 않지만 단지 가리키는 방법을 이해할 수 없다고 생각합니다. 조언을 기다리고 있습니다.

+0

이 실제로 * * 봄을 사용하고, 그것은 할 필요가있다 부트 스트랩하거나 교체해야합니다. 하지만 다른 것들보다 먼저 실제로 camel-jms 종속성을 추가했는지 확인하십시오. 이것은 클래스 경로에서 구성 요소를 놓칠 때 발생하는 오류 유형입니다. – kaqqao

답변

1

<beans/> XML은 어떤 방식 으로든 부트 스트랩되어야하는 스프링 구성입니다. 서블릿 환경에서이를 수행하는 방법을 보여주는 here이라는 Tomcat ActiveMQ 예제를 살펴볼 수 있습니다. web.xml에서 특별한 보라 : 물론

<!-- location of spring XML files --> 
<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value> 
     classpath:broker.xml, 
     classpath:camel-config.xml 
    </param-value> 
</context-param> 

<!-- the listener that kick-starts Spring, which loads the XML files and start our application --> 
<listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 

, 다음과 같이 당신은 또한 자바에만 설정을 사용할 수 있습니다 : 베드로가 말한대로

ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); 

ModelCamelContext context = new DefaultCamelContext(); 
context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); 
관련 문제