Spring Boot с Apache Camel и Active MQ и проблема Hawtio
Ошибка регистрации верблюжьих маршрутов при добавлении hawtio в качестве зависимости и настройке порта управления.
Описание:
- Создано приложение Spring Boot, Camel и Active MQ.
- Маршруты регистрируются, когда зависимость от hawtio не включена.
- Маршруты не регистрируются, когда добавлена зависимость hawtio и настроен порт управления.
Пожалуйста, найдите прикрепленные конфигурации pom.xml и application.yml
Ваша помощь и руководство очень ценится.
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.bottomline.cbe</groupId>
<artifactId>spring-boot-activemq</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-activemq</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>2.23.1</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-quartz2</artifactId>
<version>2.23.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jms</artifactId>
<version>2.22.0</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
</dependency>
<!--Begin hawtio dependancies -->
<dependency>
<groupId>io.hawt</groupId>
<artifactId>hawtio-springboot</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
<!--End hawtio dependancies -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-stream-starter</artifactId>
<version>2.23.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
application.yml:
server:
port: 8091
servlet:
contextPath: /spring-boot-activemq
spring:
activemq:
broker-url: tcp://localhost:61616
user: admin
password: admin
management:
server:
port: 9091
servlet:
context-path: /spring-boot-activemq-health
endpoints:
web:
exposure:
include: ["configprops", "env", "health", "info", "threaddump", "logfile", "hawtio", "jolokia"]
base-path: /
path-mapping:
hawtio: /hawtio/console
endpoints:
jolokia:
sensitive: false
hawtio:
authenticationEnabled: false
offline: true
camel:
springboot:
name: spring-boot-activemq
JMS Config:
@Configuration
public class JMSConfig {
String BROKER_URL = "tcp://localhost:61616";
String BROKER_USERNAME = "admin";
String BROKER_PASSWORD = "admin";
@Bean
public ActiveMQConnectionFactory connectionFactory(){
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL(BROKER_URL);
connectionFactory.setPassword(BROKER_USERNAME);
connectionFactory.setUserName(BROKER_PASSWORD);
return connectionFactory;
}
@Bean(name="activemq")
public ActiveMQComponent camelActiveMQComponent(ConnectionFactory connectionFactory) {
ActiveMQComponent activeMQComponent = new ActiveMQComponent();
activeMQComponent.setConnectionFactory(connectionFactory());
return activeMQComponent;
}
@Bean
public JmsTemplate jmsTemplate(){
JmsTemplate template = new JmsTemplate();
template.setConnectionFactory(connectionFactory());
return template;
}
@Bean
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConnectionFactory(connectionFactory());
factory.setConcurrency("1-1");
return factory;
}
}
Camel Routes:
@Component
@Slf4j
public class CamelRoutes extends RouteBuilder {
@Override
public void configure() throws Exception {
from("quartz2://testTimer?cron=0/1+5+*+?+*+*&job.name=REAL_TIME_test_JOB").routeId("test_REALTIME_QUARTZ_KICK_OFF").id("hello").log("Invoked test-Realtime job.")
.to("activemq:diistransactions");
}
}
Listener:
@JmsListener(destination = "diistransactions")
@SendTo("outbounddiis")
public String receiveMessage(final Message jsonMessage) throws JMSException {
String messageData = null;
String response = null;
System.out.println("REceived message ::"+jsonMessage);
if(jsonMessage instanceof TextMessage) {
TextMessage textMessage = (TextMessage)jsonMessage;
messageData = textMessage.getText();
response = messageData;
}
return response;
}
Ожидаемые результаты:
2019-02-12 15:59:10.267 INFO 66428 --- [ main] o.a.camel.spring.SpringCamelContext : Route: hello started and consuming from: quartz2://testTimer?cron=0%2F1+5+*+%3F+*+*&job.name=REAL_TIME_test_JOB
2019-02-12 15:59:10.267 INFO 66428 --- [ main] o.a.camel.spring.SpringCamelContext : Total 1 routes, of which 1 are started
Фактические результаты:
2019-02-12 16:00:06.741 INFO 56352 --- [ main] o.a.camel.spring.SpringCamelContext : Total 0 routes, of which 0 are started