You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jhonny <wr...@live.com> on 2013/08/30 19:22:13 UTC

How to Give any java application as a end point in from (....)

Hi,

Am Novice to Camel.

I had a java application which continuously produces the messages, i can get
this messages by implementing the one of the method [getMEssages()] in my
main class , my code looks like below

public class StandAloneCameClass implements MessageProducer {
	

	public static void main(String args[]) throws Exception {

		CamelContext context = new DefaultCamelContext();

		context.addRoutes(new RouteBuilder() {

			@Override
			public void configure() throws Exception {

				from(?????????????).process(MyProcessorInstance);

			}
		});

		context.start();
		Thread.sleep(10000);
		context.stop();
	}

	
	@Override
	public void getMessages(String s) throws Exception {
		// here am getting/received messages , which need to pass 
		// to processor
	}

}


I want to make this getMessages() as endpoint and need to pass this in from
(??????????) . 
can some one guide me on this , how should i proceed ?



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-Give-any-java-application-as-a-end-point-in-from-tp5738327.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to Give any java application as a end point in from (....)

Posted by Raul Kripalani <ra...@evosent.com>.
In a SOA-based solution, the middleware implemented by Camel would expose a
service over a standard transport/protocol like HTTP (SOAP or REST), JMS,
TCP, etc. This interface would ideally be driven by a contract.

Your producer application would then send messages via this transport to
the Camel-based integration middleware.

This is what I recommend, rather than binding the original application to
the Camel APIs. We offer 120+ adapters in the form of Camel Components to
build external interfaces, so you have huge variety to build the least
costly, most optimal communication channel in all cases.

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Fri, Aug 30, 2013 at 6:22 PM, jhonny <wr...@live.com> wrote:

> Hi,
>
> Am Novice to Camel.
>
> I had a java application which continuously produces the messages, i can
> get
> this messages by implementing the one of the method [getMEssages()] in my
> main class , my code looks like below
>
> public class StandAloneCameClass implements MessageProducer {
>
>
>         public static void main(String args[]) throws Exception {
>
>                 CamelContext context = new DefaultCamelContext();
>
>                 context.addRoutes(new RouteBuilder() {
>
>                         @Override
>                         public void configure() throws Exception {
>
>
> from(?????????????).process(MyProcessorInstance);
>
>                         }
>                 });
>
>                 context.start();
>                 Thread.sleep(10000);
>                 context.stop();
>         }
>
>
>         @Override
>         public void getMessages(String s) throws Exception {
>                 // here am getting/received messages , which need to pass
>                 // to processor
>         }
>
> }
>
>
> I want to make this getMessages() as endpoint and need to pass this in from
> (??????????) .
> can some one guide me on this , how should i proceed ?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-Give-any-java-application-as-a-end-point-in-from-tp5738327.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: How to Give any java application as a end point in from (....)

Posted by Pontus Ullgren <ul...@gmail.com>.
A simplified answer is that the seda queue is defined when you use it as a
from endpoint ie from("seda:start").

To send messages to it in your example simply use the producer template
just change so the message is send to the seda uri instead of the direct.

Best regards
Pontus
Thanks Pontus Ullgren ,
can you explain something about seda implementation, i go to url but am not
able to get much,
want to know how we define seda que and put the messages to it ?  in my
given example



--
View this message in context:
http://camel.465427.n5.nabble.com/How-to-Give-any-java-application-as-a-end-point-in-from-tp5738327p5738424.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to Give any java application as a end point in from (....)

Posted by jhonny <wr...@live.com>.
Thanks Pontus Ullgren ,
can you explain something about seda implementation, i go to url but am not
able to get much,
want to know how we define seda que and put the messages to it ?  in my
given example



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-Give-any-java-application-as-a-end-point-in-from-tp5738327p5738424.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to Give any java application as a end point in from (....)

Posted by Pontus Ullgren <ul...@gmail.com>.
If you want to call the camel route synchronously then you can use a direct
endpoint[1] and then in getMessage() use a producer template[2].
Other options are to use a seda[3] endpoint.

So something like this:

public class StandAloneCameClass implements MessageProducer {

       ProducerTemplate template;

        public static void main(String args[]) throws Exception {

                CamelContext context = new DefaultCamelContext();

                context.addRoutes(new RouteBuilder() {

                        @Override
                        public void configure() throws Exception {

                                from("direct:start").process(
MyProcessorInstance);

                        }
                });
               template = context.createProducerTemplate();

                context.start();
                Thread.sleep(10000);
                context.stop();
        }


        @Override
        public void getMessages(String s) throws Exception {
                // here am getting/received messages , which need to pass
                // to processor
               template.sendBody("direct:start", s);
        }

}


[1] http://camel.apache.org/direct.html
[2] http://camel.apache.org/producertemplate.html
[3] http://camel.apache.org/seda.html

Best regards
Pontus Ullgren


On Fri, Aug 30, 2013 at 7:27 PM, jhonny <wr...@live.com> wrote:

> getMessage() is called by the java application contiously , where it insert
> the messages coniniously
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-Give-any-java-application-as-a-end-point-in-from-tp5738327p5738328.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: How to Give any java application as a end point in from (....)

Posted by jhonny <wr...@live.com>.
getMessage() is called by the java application contiously , where it insert
the messages coniniously



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-Give-any-java-application-as-a-end-point-in-from-tp5738327p5738328.html
Sent from the Camel - Users mailing list archive at Nabble.com.