Hi

Your bean MyBean needs to be managed its lifecycle by spring, so you
can for example add a <bean id="myBean" class="...MyBean"/>

then the injection of @Producer and whatnot should happen.

On Thu, Jan 16, 2014 at 4:56 PM, m.mcinness1 <m.mcinne...@gmail.com> wrote:
> Hi.
>
> I am new to camel and I'm trying to set up a POJO producer for an activemq
> component, following the instructions here:
>
> http://camel.apache.org/pojo-producing.html
>
> I'm using camel via servicemix 4.5.3 (camel 2.10.7) and am using the
> embedded activemq broker (ActiveMQ 5.7.0).
>
> I have an interface defined as:
>
> public interface MyListener {
>     String sayHello(String name);
> }
>
> and a simple POJO producer:
>
> public class MyBean {
>     @Produce(uri = "activemq:foo")
>     protected MyListener producer;
>
>     public void doSomething() {
>         // lets send a message
>         String response = producer.sayHello("James");
>     }
> }
>
> My problem is that my producer is null and throws an NPE at
> producer.sayHello(...
>
> I guess I'm missing something in wiring this all together.
>
> I've configured a pooled connection factory and activemq component via the
> instructions here:
>
> http://camel.apache.org/activemq.html#ActiveMQ-Usingconnectionpooling
>
> as such (note, I'm using blueprint config instead of spring):
>
>         <camelContext
> xmlns="http://camel.apache.org/schema/blueprint";></camelContext>
>
>         <bean id="jmsConnectionFactory"
>           class="org.apache.activemq.ActiveMQConnectionFactory">
>             <property name="brokerURL" value="tcp://localhost:61616" />
>         </bean>
>
>         <bean id="pooledConnectionFactory"
>           class="org.apache.activemq.pool.PooledConnectionFactory"
> init-method="start" destroy-method="stop">
>             <property name="maxConnections" value="8" />
>             <property name="connectionFactory" ref="jmsConnectionFactory" />
>         </bean>
>
>         <bean id="jmsConfig"
>           class="org.apache.camel.component.jms.JmsConfiguration">
>             <property name="connectionFactory" ref="pooledConnectionFactory"/>
>             <property name="concurrentConsumers" value="10"/>
>         </bean>
>
>         <bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>             <property name="configuration" ref="jmsConfig"/>
>         </bean>
>
> Thanks for any help,
> Michael
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/camel-activemq-POJO-producer-is-null-tp5746075.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io

Reply via email to