...
Like with any other JMS-based component, usually it's important to configure JMS connection factory. For example, you'd like to set your broker url or set proper connection credentials. Additionally, you would always want to set some kind of pooling (or caching) on the connection factory. An example of how to do both of these tasks is shown below.
Code Block |
---|
<bean id="jmsConnectionFactory" class="org.apache.qpid.jms.JmsConnectionFactory">
<property name="remoteURI" value="amqp://localhost:5672" />
<property name="username" value="admin"/>
<property name="password" value="admin"/>
</bean>
<bean id="jmsCachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory" ref="jmsConnectionFactory" />
</bean>
<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration" >
<property name="connectionFactory" ref="jmsCachingConnectionFactory" />
<property name="cacheLevelName" value="CACHE_CONSUMER" />
</bean>
<bean id="amqp" class="org.apache.camel.component.amqp.AMQPComponent">
<property name="configuration" ref="jmsConfig" />
</bean>
<camelContext xmlns="http://camel.apache.org/schema/blueprint" id="simple">
<route>
<from uri="timer:simple?period=5000"/>
<setBody>
<simple>Hello World</simple>
</setBody>
<to uri="amqp:test"/>
</route>
</camelContext> |
Using inside Karaf
If you want to use amqp component inside the Karaf, there's already defined feature that will install all necessary bundles for you. All you need to do is
Code Block |
---|
karaf@root()> repo-add camel
karaf@root()> feature:install camel-amqp |
and the environment would be set. Additionally you can add camel-blueprint or camel-spring features if you want to define your routes in those contexts.
Include Page | ||||
---|---|---|---|---|
|