You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by diwakar <di...@nsn.com> on 2011/12/16 12:51:43 UTC

Camel Components as Pojos

Hi, 

           Is it possible to use Camel components withour creating/starting
Camel Context?
           We want to use the various Camel components in side our Java SE
application (without Camel routes).
           Please let me know your comment.

With Best Regards,
Diwakar


--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Components-as-Pojos-tp5080073p5080073.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Components as Pojos

Posted by Claus Ibsen <cl...@gmail.com>.
No you need a CamelContext. But a CamelContext runs fine without any routes.


On Fri, Dec 16, 2011 at 12:51 PM, diwakar <di...@nsn.com> wrote:
> Hi,
>
>           Is it possible to use Camel components withour creating/starting
> Camel Context?
>           We want to use the various Camel components in side our Java SE
> application (without Camel routes).
>           Please let me know your comment.
>
> With Best Regards,
> Diwakar
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Components-as-Pojos-tp5080073p5080073.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Camel Components as Pojos

Posted by diwakar <di...@nsn.com>.
Hi, 

           Thanks Babak.
           Following is 11 line Hello world code for Camel:

package org.apache.camel.example;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.impl.DefaultCamelContext;
public class Hello  {
    public static void main(String[] args) throws Exception {
        DefaultCamelContext camelContext = new DefaultCamelContext();
        camelContext.start();
       
camelContext.createProducerTemplate().sendBody("file://target/test-reports?fileName=Hello.World",
"The Camel riders!");
        template.sendBody("file://target/test-reports?fileName=Hello.World",
"The Camel riders!");
        camelContext.stop();
    }
}
            This creates a file named "Hello.World" with "The Camel riders!"
content at "target/test-reports".

With Best Regards,
Diwakar


--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Components-as-Pojos-tp5080073p5080943.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Components as Pojos

Posted by diwakar <di...@nsn.com>.
Hi, 

             >> As using the Camel ProducerTemplate is much easier than
working with low level API
             Thanks. I go the point now.

With Best Regards,
Diwakar


--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Components-as-Pojos-tp5080073p5080807.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Components as Pojos

Posted by bvahdat <ba...@swissonline.ch>.
Hi Diwakar,

just in the case it's still not clear to you how to take advantage of Apache
Camel *without* defining any routes the examples in [1] could clarify this
for you.

As you see there, thanks to Apache Camel we can send a JMS message to the
Broker with *one single* line of code:

// send to a specific queue
template.sendBody("activemq:MyQueue", "<hello>world!</hello>");

However using the pure JMS-API there would be much more coding to do...

And the counterpart of ProducerTemplate (message producing) is the
ConsumerTemplate [2] (message consuming) 

[1] http://camel.apache.org/producertemplate.html
[2] http://camel.apache.org/polling-consumer.html

Babak

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Components-as-Pojos-tp5080073p5080801.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Components as Pojos

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Dec 16, 2011 at 5:22 PM, diwakar <di...@nsn.com> wrote:
> Hi,
>
>             Sorry to repeat the question.
>             What is the advantage of running Camel runtime without any
> routes. Without routes Camel runtime will be idle doing nothing.
>             Please let me know your comment.
>

You do not have to use routes. For example you can use Camel to very
easily send messages to another system.
As using the Camel ProducerTemplate is much easier than working with
low level API. For example to send a message to a JMS Broker.
Or to upload a file to a FTP server etc.



> With Best Regards,
> Diwakar
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Components-as-Pojos-tp5080073p5080728.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Camel Components as Pojos

Posted by diwakar <di...@nsn.com>.
Hi, 

             Sorry to repeat the question.
             What is the advantage of running Camel runtime without any
routes. Without routes Camel runtime will be idle doing nothing. 
             Please let me know your comment.

With Best Regards,
Diwakar


--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Components-as-Pojos-tp5080073p5080728.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Components as Pojos

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Dec 16, 2011 at 5:14 PM, diwakar <di...@nsn.com> wrote:
> Hi,
>
>             >> But a CamelContext runs fine without any routes
>             How does CamelContext help without any routes?
>

CamelContext = Camel runtime.


> With Best Regards,
> Diwakar
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Components-as-Pojos-tp5080073p5080702.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Camel Components as Pojos

Posted by diwakar <di...@nsn.com>.
Hi, 

             >> But a CamelContext runs fine without any routes
             How does CamelContext help without any routes?

With Best Regards,
Diwakar

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Components-as-Pojos-tp5080073p5080702.html
Sent from the Camel - Users mailing list archive at Nabble.com.