添加hawtio作为依赖项并配置管理端口时,注册骆驼路由的问题。
说明:
请找到随附的pom.xml和application.yml配置
非常感谢您的帮助和指导。
def bray(x):
n = x.shape[0]
def diss(i,j):
l1_diff = abs(x[i,:] - x[j,:])
l1_sum = x[i,:] + x[j,:] + 1
return l1_diff.sum() / l1_sum.sum()
bray_diss_top_right = np.array([[diss(i,j) if j>i else 0. for j in range(n)] for i in range(n)])
return bray_diss_top_right + bray_diss_top_right.transpose()
预期结果:
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