Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I have an application using spring-boot, Apache Camel and active MQ. The camel routes are activeMQ queue polling routes.
- This is the camel-conext.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Configures the Camel Context-->
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:amq="http://activemq.apache.org/schema/core"
- 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
- http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
- <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="locations">
- <list>
- <value>file:${envpath}/activemqApplication.properties</value>
- </list>
- </property>
- </bean>
- <bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
- <property name="connectionFactory" ref="jmsConnectionFactory"/>
- <property name="maximumActiveSessionPerConnection" value="${message.sessions.per.connection}"/>
- <property name="maxConnections" value="${message.max.connections}"/>
- </bean>
- <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" primary="true">
- <property name="brokerURL" value="${message.broker.url}"/>
- <property name="trustAllPackages" value="true"/>
- </bean>
- <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
- <property name="connectionFactory" ref="pooledConnectionFactory"/>
- </bean>
- <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
- <property name="connectionFactory" ref="pooledConnectionFactory"/>
- <property name="transactionManager" ref="jmsTransactionManager"/>
- <property name="usePooledConnection" value="true"/>
- <property name="concurrentConsumers" value="${activemq.concurrency}" />
- </bean>
- <bean id="fileSupport" class=" com.archive.app.module.helper.filesSupport">
- </bean>
- <camelContext xmlns="http://camel.apache.org/schema/spring">
- <package>com.fileSupport.app.routes</package>
- </camelContext>
- </beans>
- These are the classes
- package com.fileSupport.app;
- import org.springframework.boot.SpringApplication;
- public final class FileSupportMain {
- public static void main(final String[] args) {
- SpringApplication app = new SpringApplication(FileArchiveSpringBootApplication.class);
- app.setWebEnvironment(false);
- app.run(args);
- }
- private FileSupportMain() {
- }
- }
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- import org.springframework.boot.context.properties.EnableConfigurationProperties;
- import org.springframework.context.annotation.ComponentScan;
- import org.springframework.context.annotation.ImportResource;
- @ImportResource({"classpath:/META-INF/spring/camel-context.xml"})
- @EnableConfigurationProperties
- @SpringBootApplication
- public class FileSupportSpringBootApplication {
- }
- package com.fileSupport.app.routes;
- import org.apache.camel.Exchange;
- import org.apache.camel.LoggingLevel;
- import org.apache.camel.builder.RouteBuilder;
- import org.apache.camel.component.jackson.JacksonDataFormat;
- import org.apache.camel.model.dataformat.JsonLibrary;
- import org.springframework.stereotype.Component;
- @Override
- public void configure() throws Exception {
- from("activemq:queue:" + Variables.RECEIVE_QUEUE1)
- .routeId("queueRoute")
- .log(LoggingLevel.INFO, "Body: $simple{body}")
- .to("activemq:queue:" + Variables.RECEIVE_QUEUE2);
- from("activemq:queue:" + Variables.RECEIVE_QUEUE2)
- .to("direct:callback");
- from("direct:callback")
- .log(LoggingLevel.INFO, "body: $simple{body}")
- .end();
- }
- }
- Would appreciate your assistance.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement