【发布时间】:2018-06-30 06:11:58
【问题描述】:
我想用 MINA 2 为 Spring 配置 Camel。
我做了如下配置代码:
@Configuration
public class SpringConfiguration {
public static final String THREADPOOL_ID = "poolId";
@Bean
CamelContextConfiguration contextConfiguration() {
return new CamelContextConfiguration() {
@Override
public void beforeApplicationStart(CamelContext context) {
context.addComponent("mina2", new Mina2Component());
}
@Override
public void afterApplicationStart(CamelContext arg0) {
}
};
}
}
但是当我像下面这样编写路由器代码时。但它不起作用:
@Component
public class RouteConfiguration extends RouteBuilder {
@Value("${app.collectorStringInput}")
private String collectorStringInput;
@Value("${app.mapOutputQueue}")
private String mapOutputQueue;
private final SiemParserProcessor parserProcessor;
public RouteConfiguration(SiemParserProcessor parser) {
this.parserProcessor = parser;
}
@Override
public void configure() throws Exception {
from("mina2:udp://10.31.0.32:514?disconnectOnNoReply=false&sync=false").to("log:edu.accs.siem.collector?level=DEBUG");
}
}
但是,我可以在日志中看到以下几行:
2018-06-30 11:37:14.270 INFO 480 --- [ restartedMain] o.a.camel.spring.SpringCamelContext : Route: route1 started and consuming from: mina2://udp://10.31.0.32:514?disconnectOnNoReply=false&sync=false
2018-06-30 11:37:14.270 INFO 480 --- [ restartedMain] o.a.camel.spring.SpringCamelContext : Total 1 routes, of which 1 are started
2018-06-30 11:37:14.271 INFO 480 --- [ restartedMain] o.a.camel.spring.SpringCamelContext : Apache Camel 2.21.1 (CamelContext: camel-1) started in 0.185 seconds
它在不使用 Spring 的情况下工作。所以我猜有一些配置问题。
谁能告诉我我错过了什么?
PS:我检查了netty,但即使不使用Spring,它似乎也无法正常工作。
【问题讨论】:
-
路线是根据您显示的日志开始的,请您详细说明为什么会出错?
-
我不知道出了什么问题。没有弹簧它正在工作。没有 spring 我不必添加任何配置
-
路线已开始。那么你可以向套接字发送一个udp数据包吗?看起来它正在运行。
-
我尝试发送打包好的。它使用 nc 命令显示。但不是 java spring 项目。
-
我的意思是 nc -ul -p 514 列出了数据包。但不是春季项目
标签: spring-boot apache-camel mina