You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Marco Mistroni <mm...@gmail.com> on 2012/06/07 23:36:58 UTC
Injecting a ProducerTemplate in a POjo
hi all
i have a camel app in which i have exposed few JMX beans.
I want to be able to send a message to a channel via my JMX bean.
I have read the POJO Producing info here
http://camel.apache.org/pojo-producing.html
and at the moment i am doing this in my JMX bean
@EndpointInject(uri="seda:testChannel")
private ProducerTemplate producer;
However, i want to be able to send messages to different channels, not only
to the uri above.
Ok i can always create a 'jmx-channel' with a router for each type of
message.,... but i was just wondering if i can just inject a
ProducerTemplate without specifying the URI/
I have tried using the @Autowired but the bean wasn't being set correctly.
(the bean was not being set ,resulting in a NullPointerException whenever i
was invoking methods on it)
here's my camelContext where i define the producer
<camel:camelContext xmlns="http://camel.apache.org/schema/spring"
id="camelServer">
<camel:template id="producer"/>
could anyone offer another suggestion (other than sending message to a
default channel associated with a router)?
w/kindest regards
marco
Re: Injecting a ProducerTemplate in a POjo
Posted by Marco Mistroni <mm...@gmail.com>.
Thanks for the explanation Claus!
regards
marco
On Fri, Jun 8, 2012 at 4:53 AM, Claus Ibsen <cl...@gmail.com> wrote:
> The ProducerTemplate has API for sending a message to *any* Camel endpoint
>
> template.sendBody("log:blah", "Hello Log");
>
> The uri in the annotation, is just the default uri, if you do not specify
> any eg
>
> template.sendBody("Hello default channel");
>
>
> On Thu, Jun 7, 2012 at 11:36 PM, Marco Mistroni <mm...@gmail.com>
> wrote:
>
> > hi all
> > i have a camel app in which i have exposed few JMX beans.
> >
> > I want to be able to send a message to a channel via my JMX bean.
> >
> > I have read the POJO Producing info here
> >
> > http://camel.apache.org/pojo-producing.html
> >
> > and at the moment i am doing this in my JMX bean
> >
> > @EndpointInject(uri="seda:testChannel")
> > private ProducerTemplate producer;
> >
> >
> > However, i want to be able to send messages to different channels, not
> only
> > to the uri above.
> >
> > Ok i can always create a 'jmx-channel' with a router for each type of
> > message.,... but i was just wondering if i can just inject a
> > ProducerTemplate without specifying the URI/
> >
> > I have tried using the @Autowired but the bean wasn't being set
> correctly.
> > (the bean was not being set ,resulting in a NullPointerException
> whenever i
> > was invoking methods on it)
> >
> > here's my camelContext where i define the producer
> >
> > <camel:camelContext xmlns="http://camel.apache.org/schema/spring"
> > id="camelServer">
> >
> > <camel:template id="producer"/>
> >
> > could anyone offer another suggestion (other than sending message to a
> > default channel associated with a router)?
> >
> > w/kindest regards
> > marco
> >
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>
Re: Injecting a ProducerTemplate in a POjo
Posted by Claus Ibsen <cl...@gmail.com>.
The ProducerTemplate has API for sending a message to *any* Camel endpoint
template.sendBody("log:blah", "Hello Log");
The uri in the annotation, is just the default uri, if you do not specify
any eg
template.sendBody("Hello default channel");
On Thu, Jun 7, 2012 at 11:36 PM, Marco Mistroni <mm...@gmail.com> wrote:
> hi all
> i have a camel app in which i have exposed few JMX beans.
>
> I want to be able to send a message to a channel via my JMX bean.
>
> I have read the POJO Producing info here
>
> http://camel.apache.org/pojo-producing.html
>
> and at the moment i am doing this in my JMX bean
>
> @EndpointInject(uri="seda:testChannel")
> private ProducerTemplate producer;
>
>
> However, i want to be able to send messages to different channels, not only
> to the uri above.
>
> Ok i can always create a 'jmx-channel' with a router for each type of
> message.,... but i was just wondering if i can just inject a
> ProducerTemplate without specifying the URI/
>
> I have tried using the @Autowired but the bean wasn't being set correctly.
> (the bean was not being set ,resulting in a NullPointerException whenever i
> was invoking methods on it)
>
> here's my camelContext where i define the producer
>
> <camel:camelContext xmlns="http://camel.apache.org/schema/spring"
> id="camelServer">
>
> <camel:template id="producer"/>
>
> could anyone offer another suggestion (other than sending message to a
> default channel associated with a router)?
>
> w/kindest regards
> marco
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen