camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Posta <christian.po...@gmail.com>
Subject Re: Send a message in the easiest way
Date Fri, 08 Nov 2013 21:43:53 GMT
Inline...

On Fri, Nov 8, 2013 at 12:46 PM, pmp.martins
<pmp.martins@campus.fct.unl.pt> wrote:
> I am trying to create a sample application hosted at
> "mina:tcp://localhost:9991" that sends a very simple message to a server
> hosted at "mina:tcp://localhost:9990".
>
> Now admittedly I have some problems understanding how to do this. My first
> approach was to create a class called Message, that had two fields: String
> order and String host. However, I am terribly confused on how to do this.
>
> First I tried to follow the loadbalancer-example basing myself on the
> ReportGenerator and create a MessageGenerator class that could create a
> message and return it:
> http://camel.apache.org/loadbalancing-mina-example.html
>
> However, there is a problem, I need parameters to create my Message,
> something that doesn't happen when creating the Report from the example.
What parameters do you need? If I understand you correctly, you want
to create a bean that "creates" your Message object, right? And you
need parameters to be passed in to your bean that are used to set the
order/host fields of the Message object?

Where would those values be? Camel really deals with the idea of an
Exchange.. this exchange can have properties and a message with
headers/body. If you want to bind specific parameters or headers to
your bean, you can do so with this:
http://camel.apache.org/bean-binding.html

>
> By reading Camel in Action In know how to use beans to call methods that
> have no parameters, however I still do not understand how I should use them
> to call a method that has several parameters (Am I forced to use
> processors?)
Check the link i posted above. That should help. Or take a look at
Camel in Action book pp 105 and 11.

>
> Then i realized that perhaps I am complicating things a little bit and there
> is an easier way to send messages. So I tried another approach that resulted
> in this small code (26 lines):
> http://pastebin.kde.org/pvedrm6er
>
> But it still does not work.
So what doesn't work?
Where/how are you invoking the route (calling the direct:start endpoint)?

> Obviously I am doing something wrong and I don't
> get what. So, I have 3 questions:
> 1 - What is the easiest way to send a very simple message to another server
> using Camel?
I think you have that already :) the loadbalancer example does that.

> 2 - What is the easiest way to create and send an object that requires
> several parameters through Camel?
If it requires parameters, you can do so w/ bean binding, or in a processor

> 3 - Is my code wrong? If yes, what is wrong with it?
Not sure yet :) You have to invoke the route some how....

>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Send-a-message-in-the-easiest-way-tp5742890.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Christian Posta
http://www.christianposta.com/blog
twitter: @christianposta

Mime
View raw message