You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by CamelNewbieUser <ha...@gmail.com> on 2013/01/21 11:10:02 UTC

Camel Routing using Java DSL in Servlet without Spring

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();
	}




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.

Re: Camel Routing using Java DSL in Servlet without Spring

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jan 25, 2013 at 10:46 AM, CamelNewbieUser
<ha...@gmail.com> wrote:
> Hi,
>
> I tried to find release date for Apache Camel 2.11 but it is nowhere
> mentioned.
> Also the links provided on the  site
> <http://www.apache.org/dyn/closer.cgi/camel/apache-camel/2.11.0/apache-camel-2.11.0.zip>
> is showing HTTP 404.
>
> I tried to download the SNAPSHOT version and build using Maven but facing
> difficulties.
>
> It would be better to have SC release.
>
> Can please help with tentative dates for the RC?
>

Sometime next month is the current ETA.


> Thanks in advance,
> Manoj
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Routing-using-Java-DSL-in-Servlet-without-Spring-tp5725880p5726239.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: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel Routing using Java DSL in Servlet without Spring

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jan 25, 2013 at 10:46 AM, CamelNewbieUser
<ha...@gmail.com> wrote:
> Hi,
>
> I tried to find release date for Apache Camel 2.11 but it is nowhere
> mentioned.
> Also the links provided on the  site
> <http://www.apache.org/dyn/closer.cgi/camel/apache-camel/2.11.0/apache-camel-2.11.0.zip>
> is showing HTTP 404.
>
> I tried to download the SNAPSHOT version and build using Maven but facing
> difficulties.
>
> It would be better to have SC release.
>
> Can please help with tentative dates for the RC?
>

You can see the JIRA roadmap for ETA dates
https://issues.apache.org/jira/browse/CAMEL#selectedTab=com.atlassian.jira.plugin.system.project%3Aroadmap-panel

> Thanks in advance,
> Manoj
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Routing-using-Java-DSL-in-Servlet-without-Spring-tp5725880p5726239.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: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel Routing using Java DSL in Servlet without Spring

Posted by CamelNewbieUser <ha...@gmail.com>.
Hi,

I tried to find release date for Apache Camel 2.11 but it is nowhere
mentioned.
Also the links provided on the  site
<http://www.apache.org/dyn/closer.cgi/camel/apache-camel/2.11.0/apache-camel-2.11.0.zip>  
is showing HTTP 404.

I tried to download the SNAPSHOT version and build using Maven but facing
difficulties.

It would be better to have SC release.

Can please help with tentative dates for the RC?

Thanks in advance,
Manoj



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Routing-using-Java-DSL-in-Servlet-without-Spring-tp5725880p5726239.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Routing using Java DSL in Servlet without Spring

Posted by Claus Ibsen <cl...@gmail.com>.
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
<ha...@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: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen