[英]Apache camel process(processor) method is not being called
I saw in another post how manually adding the camel context and starting it should work, but it hasn't for me.我在另一篇文章中看到手动添加 camel 上下文并启动它应该如何工作,但它不适合我。 I double checked the from, and to paths and they seem to be correct.
我仔细检查了 from 和 to 路径,它们似乎是正确的。 Not sure why it's not calling the method and would appreciate some advice
不确定为什么它不调用该方法并希望得到一些建议
public class CsvRouteBuilder extends DdsRouteBuilder {
private CsvConverterProcessor csvConverterProcessor;
private CamelContext camelContext;
@Autowired
public CsvRouteBuilder(CsvConverterProcessor csvConverterProcessor) throws Exception {
this.csvConverterProcessor = csvConverterProcessor;
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("{{input.files.csv}}")
.routeId("CSVConverter")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
System.out.println("hitting");
}
})
.to("{{output.files.csv}}");
}
});
camelContext.start();
}
The processor is not called simply because your route is not properly declared such that Spring Boot is not aware of it.不调用处理器只是因为您的路由未正确声明,因此 Spring Boot 不知道它。
The proper way is to make your class extend RouteBuilder to define your route(s) and annotate your class with @Component
to mark it as candidate for auto-detection when using annotation-based configuration and classpath scanning.正确的方法是让您的 class 扩展RouteBuilder以定义您的路由,并使用
@Component
注释您的 class 以在使用基于注释的配置和类路径扫描时将其标记为自动检测的候选对象。
Your code should rather be something like this:您的代码应该是这样的:
@Component
public class CsvRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
from("{{input.files.csv}}")
.routeId("CSVConverter")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
System.out.println("hitting");
}
})
.to("{{output.files.csv}}");
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.