Hi

See this example
http://camel.apache.org/servlet-tomcat-example.html

And from Camel 2.11 onwards you can do this without Spring, or the
likes to bootstap your app
http://camel.apache.org/servlet-tomcat-no-spring-example.html



On Mon, Jan 21, 2013 at 11:10 AM, CamelNewbieUser
<harddrive.ma...@gmail.com> wrote:
> Hi Geeks,
>
> Outline of the task:
>
> 1. I have a simple web application with index.jsp as welcome page having one
> text input box and submit button, which is used to POST the parameter from
> index.jsp to Servlet
>
> 2. This servlet is invoking one method routing which has CamelContext
> initialization and route to different HTTP location along with POST
> parameter received from index.jsp
>
>
> Method: (The method routing is configured as below)
>
>
>
> public void routing() throws Exception
>         {
>                 CamelContext context = new DefaultCamelContext();
>
>                 System.out.println("Routing through camel JAVA DSL");
>                 context.addRoutes(new RouteBuilder() {
>             public void configure() {
>                 from("servlet://CamelDSLServlet").
>
> to("http://localhost:9090/RestfulDemo/rest/hello/jsonString?bridgeEndpoint=true&amp;throwExceptionOnFailure=false";);
>
>             }
>         });
>                 System.out.println("Routing done");
>                 context.start();
>
>                 Thread.sleep(1000L);
>
>                 context.stop();
>         }
>


The code above is wrong as you just keep Camel running for 1 sec.
You need to bootstrap/start Camel as part of the web application.
eg the links in the top for the examples.



>
>
>
> This servlet I have declared as CamelHttpTransportServlet in web.xml.
>
>
> Please suggest if above setup is right?
> As I am trying to execute, this System.out.println statements getting
> executed but no actual routing  is happening.
>
> How to redirect from CamelContext to ServletContext to refer to other URL
> from above example?
>
> Please guide.
>
> Thanks in advance.
>
> Manoj
>
>
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Camel-Routing-using-Java-DSL-in-Servlet-without-Spring-tp5725880.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to