Camel Route as a String load and Run

471 Views Asked by At

I have created camel route and store in database, i need to load and run.

Till now i am created code which is created route dynamically but result is not as per an expectation.

I have downloaded example of CXF and run using mvn camel:run it was run and as result it was calling web service, but now i need a create java project and call, I have camel Route in String variable. so load route which is store as String, and call web service.

Code For Same:

    public static void main(String[] args) throws Exception {
    DefaultCamelContext context = new DefaultCamelContext();

    // append the routes to the context
    String myString = "<route id=\"my_Sample_Camel_Route_with_CXF\" xmlns=\"http://camel.apache.org/schema/spring\">"
            + "      <from uri=\"file:src/data?noop=true\"/>"
            + "    <log loggingLevel=\"INFO\" message=\"&gt;&gt;&gt; ${body}\"/>"
            + "   <to uri=\"cxf://http://www.webservicex.net/stockquote.asmx?wsdlURL=src/wsdl/stockquote.wsdl&amp;serviceName={http://www.webserviceX.NET/}StockQuote&amp;portName={http://www.webserviceX.NET/}StockQuoteSoap&amp;dataFormat=MESSAGE\"/>"
            + "  <log loggingLevel=\"INFO\" message=\"&gt;&gt;&gt; ${body}\"/>"
            + "    </route>";
    ;

    InputStream is = new ByteArrayInputStream(myString.getBytes());
    RoutesDefinition routes = context.loadRoutesDefinition(is);
    context.addRouteDefinitions(routes.getRoutes());
    context.setTracing(true);
    // at the end start the camel context
    context.start();

    Thread.sleep(3000);
    context.stop();

    System.out.println("Done");

    /***
     *  Jars are 
     *  
            aopalliance-1.0.jar
            asm-3.3.jar
            camel-core-2.6.0-fuse-00-00.jar
            camel-cxf-2.6.0-fuse-00-00.jar
            camel-http-2.6.0-fuse-00-00.jar
            camel-spring-2.6.0-fuse-00-00.jar
            commons-codec-1.2.jar
            commons-httpclient-3.1.jar
            commons-logging-1.1.1.jar
            commons-logging-api-1.1.jar
            commons-management-1.0.jar
            cxf-api-2.3.2-fuse-00-00.jar
            cxf-common-schemas-2.3.2-fuse-00-00.jar
            cxf-common-utilities-2.3.2-fuse-00-00.jar
            cxf-rt-bindings-soap-2.3.2-fuse-00-00.jar
            cxf-rt-bindings-xml-2.3.2-fuse-00-00.jar
            cxf-rt-core-2.3.2-fuse-00-00.jar
            cxf-rt-databinding-jaxb-2.3.2-fuse-00-00.jar
            cxf-rt-frontend-jaxrs-2.3.2-fuse-00-00.jar
            cxf-rt-frontend-jaxws-2.3.2-fuse-00-00.jar
            cxf-rt-frontend-simple-2.3.2-fuse-00-00.jar
            cxf-rt-transports-common-2.3.2-fuse-00-00.jar
            cxf-rt-transports-http-2.3.2-fuse-00-00.jar
            cxf-rt-ws-addr-2.3.2-fuse-00-00.jar
            cxf-tools-common-2.3.2-fuse-00-00.jar
            geronimo-javamail_1.4_spec-1.7.1.jar
            geronimo-servlet_2.4_spec-1.1.1.jar
            jaxb-impl-2.1.13.jar
            jettison-1.2.jar
            jsr311-api-1.1.1.jar
            log4j-1.2.16.jar
            neethi-2.0.4.jar
            spring-aop-3.0.5.RELEASE.jar
            spring-asm-3.0.5.RELEASE.jar
            spring-beans-3.0.5.RELEASE.jar
            spring-context-3.0.5.RELEASE.jar
            spring-core-3.0.5.RELEASE.jar
            spring-expression-3.0.5.RELEASE.jar
            spring-tx-3.0.5.RELEASE.jar
            spring-web-3.0.5.RELEASE.jar
            stax2-api-3.0.2.jar
            woodstox-core-asl-4.0.8.jar
            wsdl4j-1.6.2.jar
            xml-resolver-1.2.jar
            XmlSchema-1.4.7.jar
     */
}

After running same program i am getting out like

Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
                log4j:WARN No appenders could be found for logger (org.apache.camel.impl.DefaultCamelContext).
                log4j:WARN Please initialize the log4j system properly.
                log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
                Jun 11, 2015 12:36:19 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
                INFO: Creating Service {http://www.webserviceX.NET/}StockQuote from WSDL: src/wsdl/stockquote.wsdl
                Done
0

There are 0 best solutions below