Apache Camel Query String для сценария через exec - PullRequest
0 голосов
/ 03 октября 2018

Я новичок в Apache Camel и пытался выполнить скрипт PHP, работающий на одной из моих систем.Я работаю над переписыванием PHP и решил поставить Apache Camel впереди.Для этого я использую apache-сервлет вместе со скриптом apache-exec, ниже приведен фрагмент:

import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;

public class apiRoute extends RouteBuilder {
    @Override
    public void configure() throws Exception {
        /* PHP Script execution */
        from("servlet://runPhp?matchOnUriPrefix=false")     
        .transform().simple("${headers.CamelHttpQuery.replaceAll('&','-')}")        
        .to("stream:out")
        .toD("exec:/usr/bin/php?args=/antique/consume_orders.php ${headers.CamelHttpQuery}");
    }
}

Когда я вызываю веб-приложение с одним объектом строки запроса (http://localhost:8080/antiques/api/runphp?order=123) строка запроса order=123 передается в скрипт php и выполняется.

Когда я вызываю веб-приложение с более чем одним параметром строки запроса (http://localhost:8080/antiques/api/runphp?order=123&type=new) Apache Camel вылетает с ошибкой. Может кто-нибудь посоветовать мнекак это сделать. Я пытался гуглить, но не помогала, поэтому обратилась за советом к экспертам.

Ошибка:

org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: exec:///usr/php/bin/php?args=%2Fantique%2Fconsume_orders.php+order%3D123&type=new due to: Failed to resolve endpoint: exec:///usr/php/bin/php?args=%2Fantique%2Fconsume_orders.php+order%3D123&type=new due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{type=new}]
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:758) ~[camel-core-2.22.1.jar:2.22.1]
at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:80) ~[camel-core-2.22.1.jar:2.22.1]
at org.apache.camel.util.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:91) ~[camel-core-2.22.1.jar:2.22.1]
at org.apache.camel.processor.SendDynamicProcessor.resolveEndpoint(SendDynamicProcessor.java:239) ~[camel-core-2.22.1.jar:2.22.1]
at org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:134) ~[camel-core-2.22.1.jar:2.22.1]
at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:181) ~[camel-core-2.22.1.jar:2.22.1]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) [camel-core-2.22.1.jar:2.22.1]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.22.1.jar:2.22.1]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:138) [camel-core-2.22.1.jar:2.22.1]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:101) [camel-core-2.22.1.jar:2.22.1]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.22.1.jar:2.22.1]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97) [camel-core-2.22.1.jar:2.22.1]
at org.apache.camel.http.common.CamelServlet.doService(CamelServlet.java:208) [camel-http-common-2.22.1.jar:2.22.1]
at org.apache.camel.http.common.CamelServlet.service(CamelServlet.java:78) [camel-http-common-2.22.1.jar:2.22.1]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) [servlet-api.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [catalina.jar:9.0.5]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:9.0.5]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) [tomcat-websocket.jar:9.0.5]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:9.0.5]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:9.0.5]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:185) [catalina.jar:9.0.5]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [catalina.jar:9.0.5]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) [catalina.jar:9.0.5]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [catalina.jar:9.0.5]
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651) [catalina.jar:9.0.5]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [catalina.jar:9.0.5]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [catalina.jar:9.0.5]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:409) [tomcat-coyote.jar:9.0.5]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:9.0.5]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754) [tomcat-coyote.jar:9.0.5]
at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1728) [tomcat-coyote.jar:9.0.5]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:9.0.5]
at org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:1007) [tomcat-coyote.jar:9.0.5]
at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$4.completed(Nio2Endpoint.java:540) [tomcat-coyote.jar:9.0.5]
at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$4.completed(Nio2Endpoint.java:518) [tomcat-coyote.jar:9.0.5]
at org.apache.tomcat.util.net.SecureNio2Channel$1.completed(SecureNio2Channel.java:918) [tomcat-coyote.jar:9.0.5]
at org.apache.tomcat.util.net.SecureNio2Channel$1.completed(SecureNio2Channel.java:851) [tomcat-coyote.jar:9.0.5]
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126) [?:1.8.0_161]
at sun.nio.ch.Invoker$2.run(Invoker.java:218) [?:1.8.0_161]
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112) [?:1.8.0_161]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_161]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_161]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:9.0.5]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161]
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: exec:///usr/php/bin/php?args=%2Fantique%2Fconsume_orders.php+order%3D123&type=new due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{type=new}]
at org.apache.camel.impl.DefaultComponent.validateParameters(DefaultComponent.java:215) ~[camel-core-2.22.1.jar:2.22.1]
at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:139) ~[camel-core-2.22.1.jar:2.22.1]
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:711) ~[camel-core-2.22.1.jar:2.22.1]
... 43 more
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...