我是 Camel 新手,尝试使用 #class (或 #bean)配置 sql 端点的 rowmapper 属性。两者似乎都不起作用,因为它总是被视为字符串
public String getDBRouteURI() {
String dbRouteURI = "sql:select * from " + importConfig.getImporttable() + " where PROCESSED_STATUS = 0?"
+ "outputType=SelectOne&" + "delay=10000&" + "rowMapperFactory=#bean:ROWFACTORY";
return dbRouteURI;
}
及以后
@Override
public void configure() throws Exception {
getCamelContext().getRegistry().bind("ROWFACTORY", new FileImportModelMapperFactory());
from(
toD(importUtils.getDBRouteURI()).
to("stream:out");
}
这也不起作用
public String getDBRouteURI() {
String dbRouteURI = "sql:select * from " + importConfig.getImporttable() + " where PROCESSED_STATUS = 0?"
+ "outputType=SelectOne&" + "delay=10000&" + "rowMapperFactory=#class:<className>";
return dbRouteURI;
这是异常堆栈跟踪
原因:java.lang.IllegalArgumentException:值#bean:ROWFACTORY转换为org.apache.camel.component.sql.RowMapperFactory不能为空 在 org.apache.camel.support.CamelContextHelper.mandatoryConvertTo(CamelContextHelper.java:178) 在 org.apache.camel.support.DefaultComponent.getAndRemoveParameter(DefaultComponent.java:507)
在通过代码进行调试时,整个“#bean:ROWFACTORY”将作为字符串传递。我指的是这里的文档 - https://camel.apache.org/manual/faq/how-do-i-configure-endpoints.html
感谢您发现这一点。我创建了一个 JIRA 票证,以便可以在未来的 Camel 版本中修复此问题 https://issues.apache.org/jira/browse/CAMEL-21406