我如何在Camel的DSL中表示这条路线:
<camel:camelContext id="camel-context">
<camel:route id="conductor-event" trace="true">
<camel:from uri="direct:conductor/event"/>
<camel:log message="handling conductor-event: id=${exchangeId}"/>
<!-- execute each filter in sorted order -->
<camel:bean ref="beaner.BProcessors"/>
<camel:log message="after: [bprocessors]: id=${exchangeId}"/>
<!-- map the event to a route -->
<camel:recipientList parallelProcessing="false">
<camel:method ref="beaner.Mappings" />
</camel:recipientList>
<camel:log message="after event mapping: id=${exchangeId}"/>
</camel:route>
</camel:camelContext>
到目前为止我有这个,但是我得到了一个“引起:java.net.URISyntaxException:索引0处的方案名称中的非法字符:%7BCamelToEndpoint = ...”:
RouteDefinition routeDef = from("direct:conductor/event")
.log( "handling conductor-event: id=${exchangeId}" )
.beanRef( "beaner.BProcessors" )
.log( "after: [bprocessors]: id=${exchangeId}" );
ExpressionClause<RecipientListDefinition<RouteDefinition>> recipientList = routeDef.recipientList();
recipientList.properties().setParallelProcessing( false );
recipientList.method( "beaner.EventMappings" );
routeDef.log( "after event mapping: id=${exchangeId}" );
答案 0 :(得分:2)
这是JavaDSL中的路由...请注意,默认情况下,recipientList parallelProcessing为false ...
from("direct:conductor/event")
.log("handling conductor-event: id=${exchangeId}")
.beanRef("beaner.BProcessors")
.log("after: [bprocessors]: id=${exchangeId}")
.recipientList(bean("beaner.Mappings"))
.log("after event mapping: id=${exchangeId}");
答案 1 :(得分:-1)
您应该使用Java DSL中的RouteBuilder类来访问DSL。 然后在configure方法中,您可以构建几乎与XML DSL相同的路由。
请参阅此处的入门指南:http://camel.apache.org/walk-through-an-example.html