Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Camel route with no "to" endpoint

Tags:

apache-camel

I am using Apache Camel to assist with capturing message data emitted by a third party software package. In this particular instance, I only need to capture what is produced by the software, there is no receiver on the other end (really no "end" to go to).

So, I tried to set up a route with just the "from" endpoint and no "to" endpoint. Apparently this is incorrect usage as I received the following exception:

[2018-08-15 11:08:03.205] ERROR: string.Launcher:191 - Exception
org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> From[mina:udp://localhost:9877?sync=false] <<< in route: Route(route1)[[From[mina:udp://localhost:9877?sync=false]] -... because of Route route1 has no output processors. You need to add outputs to the route such as to("log:foo").
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1063)
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)
    at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:974)
    at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3301)
    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3024)
    at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175)
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2854)
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2850)
    at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2873)
    at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2850)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
    at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2819)
    at {removed}.Launcher.startCamel(Launcher.java:189)
    at {removed}.Launcher.main(Launcher.java:125)
Caused by: java.lang.IllegalArgumentException: Route route1 has no output processors. You need to add outputs to the route such as to("log:foo").
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1061)
    ... 13 more

How do I set up a camel route that allows me to intercept (capture) the message traffic coming from the source, and not send it "to" anything? There is no need for a receiver. What would be an appropriate "to" endpoint that just drops everything it receives?

The exception suggestion of to("log:foo"). What does this do?

like image 234
Joseph Gagnon Avatar asked Aug 15 '18 15:08

Joseph Gagnon


2 Answers

You can see if the Stub component can help

http://camel.apache.org/stub.html

Example:

from("...")
    .to("stub:nowhere");
like image 68
vikingsteve Avatar answered Sep 19 '22 14:09

vikingsteve


The exception suggestion of to("log:foo"). What does this do?

It sends your route messages to an endpoint with a component of type log: (http://camel.apache.org/log.html) - component which basically dumps message contents (body and/or headers and/or properties) to your log file using appropriate log category.

If you just want to drop everything received, it's a good choice:

to("log:com.company.camel.sample?level=TRACE&showAll=true&multiline=true")
like image 33
TacheDeChoco Avatar answered Sep 16 '22 14:09

TacheDeChoco