[원본 출처] http://servicemix.apache.org/docs/5.0.x/activemq/activemq-camel-example.html


Using ActiveMQ with Camel (Camel을 가지고 ActiveMQ 사용하기)

Using Spring-DM (Spring-DM 사용하기)

It is often easy to define two application contexts for spring-dm, it helps you re-use configuration in Junit tests and cleanly separates OSGi from the normal spring application contexts.
그건은 종종 spring-dm을 위한 두개의 어플리케이션 컨텍스트를 정의하는 것이 쉽고 그것은 당신이 JUnit 테스트에서 환경구성을 재사용하고 보통의 Spring 어플리케이션 컨텍스트들로 부터 OSGi를 깨끗하게 분리하는 것을 돕는다.

You define these files in a bundle by adding them to the classpath under META-INF/spring
당신은 번들에서 META-INF/spring 폴더 아래 클래스패스에 그것들을 추가 함으로써 그 파일들을 정의하라

OSGi Application context (OSGi 어플리케이션 컨텍스트)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:ctx="http://www.springframework.org/schema/context"
  xmlns:osgi="http://www.springframework.org/schema/osgi"
  xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
  xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
    http://www.springframework.org/schema/osgi-compendium http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd">

    <!-- Make sure we use the ServiceMix provided connection pool in our beans -->
    <osgi:reference id="jmsConnectionPool" interface="javax.jms.ConnectionFactory"/>

</beans>

Normal spring application context. (일반적인 Spring 어플리케이션 컨텍스트)

<?xml version="1.0" encoding="UTF-8"?>
<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-2.5.xsd
        http://camel.apache.org/schema/spring
        http://camel.apache.org/schema/spring/camel-spring-${camel-version}.xsd">

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="jms:queue:start"/>
            <to uri="mock:result"/>
        </route>
    </camelContext>

    <!-- This bean will import use the OSGi service from the context above -->
    <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
        <property name="connectionFactory" ref="jmsConnectionPool" />
        <!-- If you have a transaction manager configured
        <property name="transacted" value="true" />
        <property name="transactionManager" ref="transactionManager" />
        -->
    </bean>

</beans>



번역자 주) 한번에 전체를 지정해주는 것이 아니라 jms Connection 의 경우 OSGi 에 구현해 두고 일반적인 어플리케이션에서는 그것을 ref로 참조한 Jms 컴포넌트를 사용하는 것을 말한다.




+ Recent posts