Reputation: 11
I want to start my route by calling an URL. My start-route isn't ready yet, but works perfectly fine. My problem is, that i get an error message when i am using the rest-route, which calls the start-route.
public class MyRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
restConfiguration().component("restlet")
.host("localhost").port("8080");
rest()
.get()
.route()
.to("direct:start");
from("direct:start")
.setHeader(HTTP_METHOD, constant("GET"))
.to("http4://{host}:{port}/api/v2/data/adapter?authUsername=username&authPassword=pw&authenticationPreemptive=true")
.process(Utils.javascript("converter.js"))
.enrich("direct:add", new MyAggregationStrategy())
//Mapping der JSON zur XML-Konfiguration
//.to("file:E:\\ApacheServiceMix\\apache-servicemix-7.0.1\\deploy")
.to("file:C:\\Users\\dwiesemann\\Desktop\\myTestOrdner")
.log("${body}");
from("direct:add")
.setHeader(HTTP_METHOD, constant("GET"))
.to("http4://{host}:{port}/api/v2/data/application?authUsername=username&authPassword=pw&authenticationPreemptive=true")
.process(Utils.javascript("converter.js"));
}
}
I can start the program without any errors. The error occurs when I call the URL (http://localhost:8080/?restletMethods=GET). However, the error only comes up, if the request to the api (from which I retrieve a JSON) is in the start route. When I comment these two lines out everything works as it's supposed to and I receive no error message. Otherwise the following error message pops up:
Jul 23, 2019 3:31:38 PM org.restlet.engine.connector.NetServerHelper$1 rejectedExecution
WARNUNG: Unable to run the following server-side task: sun.net.httpserver.ServerImpl$Exchange@327acd17
Upvotes: 1
Views: 640
Reputation: 11
Code is now working. I had to change the "to" to "toD" and set "bridgeEndpoint=true" (in the URL) so the header is ignored by the HttpProducer.
public class MyRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
restConfiguration().component("restlet")
.host("localhost").port("8080");
rest()
.get()
.route()
.to("direct:start");
from("direct:start")
.toD("http4://{host}:{port}/api/v2/data/adapter?authUsername=username&authPassword=pw&authenticationPreemptive=true&bridgeEndpoint=true")
.process(Utils.javascript("converter.js"))
.enrich("direct:add", new MyAggregationStrategy())
//Mapping der JSON zur XML-Konfiguration
//.to("file:E:\\ApacheServiceMix\\apache-servicemix-7.0.1\\deploy")
.setHeader(Exchange.FILE_NAME, constant("testDok.json"))
.to("file:C:\\Users\\dwiesemann\\Desktop\\myTestOrdner")
.log("${body}");
from("direct:add")
.toD("http4://{host}:{port}/api/v2/data/application?authUsername=username&authPassword=pw&authenticationPreemptive=true&bridgeEndpoint=true")
.process(Utils.javascript("converter.js"));
}
}
Upvotes: 0