Apache camel 使用apachecamel执行窃听
我需要用骆驼做窃听 下面是我写的一段代码Apache camel 使用apachecamel执行窃听,apache-camel,Apache Camel,我需要用骆驼做窃听 下面是我写的一段代码 from("jetty:http://xyz:8080?enableMultipartFilter=false") .streamCaching() .wireTap("direct:tap").copy(true).process(new WireTapProcessor()).end() .process(new RequestProcessor()) .to("file
from("jetty:http://xyz:8080?enableMultipartFilter=false")
.streamCaching()
.wireTap("direct:tap").copy(true).process(new WireTapProcessor()).end()
.process(new RequestProcessor())
.to("file:Z:/Testing/input");
当执行上述代码时,它给我一个异常,NoDirectConsumersAvailable
请您建议如何在上述场景中执行窃听好吧,您将窃听发送给直接消费者,但您没有创建直接消费者路线,或者换句话说,您从未定义处理窃听的其他路线。我在这里使用seda队列,而不是直接队列 请尝试以下操作:
from("jetty:http://xyz:8080?enableMultipartFilter=false")
.streamCaching()
.wireTap("seda:wiretapqueue")
.process(new RequestProcessor())
.to("file:Z:/Testing/input");
from("seda:wiretapqueue").to("somecomponent:foo");
这将解决您的问题。另请参见使用上面的它给我异常:它给我异常:线程“main”org.apache.camel.FailedToStartRouteException中的异常:无法启动路由route2,因为不允许使用同一端点的多个使用者:endpoint[direct://tap]位于org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:2142)我们已经添加了routebuilder并按如下方式启动了camel:Main Main=new Main();Main.enableHangupSupport();Main.addRouteBuilder(new XyzRouteBuilder());Main.run(args);请在seda队列中试用它。您应该使用.wireTap(“direct:mytap”),然后使用from(“direct:mytap”)