camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Injecting a ProducerTemplate in a POjo
Date Fri, 08 Jun 2012 03:53:50 GMT
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 <mmistroni@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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message