Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. I have an application using spring-boot, Apache Camel and active MQ. The camel routes are activeMQ queue polling routes.
  2.  
  3. This is the camel-conext.xml
  4.  
  5. <?xml version="1.0" encoding="UTF-8"?>
  6. <!-- Configures the Camel Context-->
  7.  
  8. <beans xmlns="http://www.springframework.org/schema/beans"
  9. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  10. xmlns:amq="http://activemq.apache.org/schema/core"
  11. xsi:schemaLocation="
  12. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  13. http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
  14. http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
  15.  
  16. <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  17. <property name="locations">
  18. <list>
  19. <value>file:${envpath}/activemqApplication.properties</value>
  20.  
  21. </list>
  22. </property>
  23. </bean>
  24.  
  25.  
  26. <bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
  27. <property name="connectionFactory" ref="jmsConnectionFactory"/>
  28. <property name="maximumActiveSessionPerConnection" value="${message.sessions.per.connection}"/>
  29. <property name="maxConnections" value="${message.max.connections}"/>
  30. </bean>
  31.  
  32. <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" primary="true">
  33. <property name="brokerURL" value="${message.broker.url}"/>
  34. <property name="trustAllPackages" value="true"/>
  35. </bean>
  36.  
  37. <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
  38. <property name="connectionFactory" ref="pooledConnectionFactory"/>
  39. </bean>
  40.  
  41. <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
  42. <property name="connectionFactory" ref="pooledConnectionFactory"/>
  43. <property name="transactionManager" ref="jmsTransactionManager"/>
  44. <property name="usePooledConnection" value="true"/>
  45. <property name="concurrentConsumers" value="${activemq.concurrency}" />
  46. </bean>
  47.  
  48.  
  49.  
  50. <bean id="fileSupport" class=" com.archive.app.module.helper.filesSupport">
  51. </bean>
  52.  
  53.  
  54. <camelContext xmlns="http://camel.apache.org/schema/spring">
  55. <package>com.fileSupport.app.routes</package>
  56.  
  57. </camelContext>
  58.  
  59. </beans>
  60.  
  61.  
  62. These are the classes
  63.  
  64. package com.fileSupport.app;
  65.  
  66. import org.springframework.boot.SpringApplication;
  67.  
  68. public final class FileSupportMain {
  69.  
  70. public static void main(final String[] args) {
  71. SpringApplication app = new SpringApplication(FileArchiveSpringBootApplication.class);
  72. app.setWebEnvironment(false);
  73. app.run(args);
  74. }
  75.  
  76. private FileSupportMain() {
  77. }
  78. }
  79.  
  80. import org.springframework.boot.autoconfigure.SpringBootApplication;
  81. import org.springframework.boot.context.properties.EnableConfigurationProperties;
  82. import org.springframework.context.annotation.ComponentScan;
  83. import org.springframework.context.annotation.ImportResource;
  84.  
  85. @ImportResource({"classpath:/META-INF/spring/camel-context.xml"})
  86. @EnableConfigurationProperties
  87.  
  88. @SpringBootApplication
  89. public class FileSupportSpringBootApplication {
  90. }
  91.  
  92. package com.fileSupport.app.routes;
  93.  
  94.  
  95.  
  96. import org.apache.camel.Exchange;
  97. import org.apache.camel.LoggingLevel;
  98. import org.apache.camel.builder.RouteBuilder;
  99. import org.apache.camel.component.jackson.JacksonDataFormat;
  100. import org.apache.camel.model.dataformat.JsonLibrary;
  101. import org.springframework.stereotype.Component;
  102.  
  103. @Override
  104. public void configure() throws Exception {
  105.  
  106.  
  107. from("activemq:queue:" + Variables.RECEIVE_QUEUE1)
  108. .routeId("queueRoute")
  109.  
  110. .log(LoggingLevel.INFO, "Body: $simple{body}")
  111. .to("activemq:queue:" + Variables.RECEIVE_QUEUE2);
  112.  
  113. from("activemq:queue:" + Variables.RECEIVE_QUEUE2)
  114. .to("direct:callback");
  115.  
  116. from("direct:callback")
  117.  
  118. .log(LoggingLevel.INFO, "body: $simple{body}")
  119.  
  120. .end();
  121.  
  122. }
  123. }
  124.  
  125.  
  126. Would appreciate your assistance.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement