使用 MINA 2 为 Spring 配置 Camel
Configuring Camel for Spring with MINA 2
我想用 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.
似乎也无法正常工作
我成功了。
实际上,这是处理,
但不知何故,日志记录没有显示。
我想用 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.
似乎也无法正常工作我成功了。 实际上,这是处理, 但不知何故,日志记录没有显示。