Apache骆驼直接在骆驼层中使用经典XML配置在独立中运行
在Apache Camel 3.17+中,是否可以直接包含XML DSL路由定义,因此我可以在独立的情况下运行它。
使用Java DSL,可以使用AddRoutesBuilders()
添加Java路由配置,如下所示。
我想将XML上下文直接添加到Main()。
public class MainApp {
public static void main(String... args) throws Exception {
Main main = new Main();
main.configure().addRoutesBuilder(new MyRouteBuilder());
main.run(args);
}
}
public class MyRouteBuilder extends RouteBuilder {
public void configure() {
from("direct:start")
.to("mock:result");
}
}
是否可以使用CamelContext标签在基于XML的DSL中使用Camel-Main
进行?
以下是样本XML
<!-- spring xmlns added removed here for make the xml brief -->
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"....
<camelContext xmlns = "http://camel.apache.org/schema/spring">
<route>
<from uri = "direct:input"/>
<log message = "log message for demo"/>
<to uri = "file:src/main/resources/data/"/>
</route>
</camelContext>
In Apache Camel 3.17+, is there a way to include xml DSL route definition directly, so I can run it in standalone.
With JAVA DSL the java route configuration can be added to the Main() context using addRoutesBuilders()
, like in below example.
I wanted to add the xml context directly to the Main().
public class MainApp {
public static void main(String... args) throws Exception {
Main main = new Main();
main.configure().addRoutesBuilder(new MyRouteBuilder());
main.run(args);
}
}
public class MyRouteBuilder extends RouteBuilder {
public void configure() {
from("direct:start")
.to("mock:result");
}
}
Is it possible to use camel-main
for routes defined in xml based DSL using camelContext tags?
Below is the sample xml
<!-- spring xmlns added removed here for make the xml brief -->
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"....
<camelContext xmlns = "http://camel.apache.org/schema/spring">
<route>
<from uri = "direct:input"/>
<log message = "log message for demo"/>
<to uri = "file:src/main/resources/data/"/>
</route>
</camelContext>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们可以在
pom.xml
中使用以下依赖关系。Camel-Spring-XML
&amp;Camel-spring-Main
Resources/Meta-Inf/Spring/*。XML
中创建XML来自动扫描基于Spring Bean的配置。we can use below dependency in
pom.xml
.camel-spring-xml
&camel-spring-main
resources/META-INF/spring/*.xml
.