How camel resolve JNDI End point

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

How camel resolve JNDI End point

Bob G.-2
Hello

I am trying to configure Camel to use JMS end point into Websphere 6.1 (was). My end point cannot be found because of some Spring JNDI lookup problem.

Some question :
-  How do I tell Camel to use my Spring JndiTemplate or JndiDestinationResolver so that my jms queue will be resolved properly?

In the documentation, it says that Camel uses Spring JmsTemplate. How can I tell Camel to use my JmsTemplate configured for Websphere?

There is my config:

<beans>
        <bean id="camel" class="org.apache.camel.spring.CamelContextFactoryBean">
                <property name="packages" value="com.abc.poc.camel.jms"/> 
        </bean>


         
        <bean id="jmsQueueTemplate"         class="org.springframework.jms.core.JmsTemplate">
          <property name="connectionFactory" ref="internalJmsQueueConnectionFactory"/>   
          <property name="destinationResolver" ref="jmsDestinationResolver"/>
          <property name="pubSubDomain"> <value>false</value>  </property>
          <property name="receiveTimeout"> <value>20000</value> </property>
        </bean>

   
    <bean id="jmsDestinationResolver"      class="org.springframework.jms.support.destination.JndiDestinationResolver">
        <property name="jndiTemplate" ref="jndiTemplate"/>
        <property name="cache" value="true"/>
    </bean>

 
  <bean id="internalJmsQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"> 
        <property name="jndiTemplate" ref="jndiTemplate"/>
    <property name="jndiName"> <value>jms/myConFactory</value>  </property>
  </bean>
 
  <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
                <property name="environment">
                        <props><prop key="java.naming.factory.initial">
                                        com.ibm.websphere.naming.WsnInitialContextFactory
                                </prop>
                        </props>
                </property>
        </bean>
</beans>


Thank you.

Reply | Threaded
Open this post in threaded view
|

Re: How camel resolve JNDI End point

Hiram Chirino
Hi Bob,

I just committed a change so that the DestiantionResolver property is
supported on the camel JMS component.  So once you pick up that
updated.  You should be able to do the following:

<beans>
       <bean id="camel" class="org.apache.camel.spring.CamelContextFactoryBean">
               <property name="packages" value="com.abc.poc.camel.jms"/>
       </bean>

       <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
          <property name="connectionFactory"
ref="internalJmsQueueConnectionFactory"/>
          <property name="destinationResolver" ref="jmsDestinationResolver"/>
       </bean>

       <!-- JMS Destination Resolver -->
      <bean id="jmsDestinationResolver"
class="org.springframework.jms.support.destination.JndiDestinationResolver">
       <property name="jndiTemplate" ref="jndiTemplate"/>
       <property name="cache" value="true"/>
      </bean>

      <!-- JMS Queue Connection Factory -->
      <bean id="internalJmsQueueConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
       <property name="jndiTemplate" ref="jndiTemplate"/>
       <property name="jndiName"> <value>jms/myConFactory</value>  </property>
      </bean>

      <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
               <property name="environment">
                       <props><prop key="java.naming.factory.initial">

com.ibm.websphere.naming.WsnInitialContextFactory
                               </prop>
                       </props>
               </property>
       </bean>
</beans>

I have also made the JMS component support auto wiring the
destinationResolver property so that the above example should also
work even if you don't define the "jms" component explicitly.  But I
figure being explicit is sometimes more clear.

Please let me know if this fixes it for you.

On 10/4/07, Bob G. <[hidden email]> wrote:

>
> Hello
>
> I am trying to configure Camel to use JMS end point into Websphere 6.1
> (was). My end point cannot be found because of some Spring JNDI lookup
> problem.
>
> Some question :
> -  How do I tell Camel to use my Spring JndiTemplate or
> JndiDestinationResolver so that my jms queue will be resolved properly?
>
> In the documentation, it says that Camel uses Spring JmsTemplate. How can I
> tell Camel to use my JmsTemplate configured for Websphere?
>
> There is my config:
>
> <beans>
>         <bean id="camel" class="org.apache.camel.spring.CamelContextFactoryBean">
>                 <property name="packages" value="com.abc.poc.camel.jms"/>
>         </bean>
>
>
>          <!-- ?? My JmsTemplate is not injected or Used in any Camel Classes ?? -->
>         <bean id="jmsQueueTemplate"
> class="org.springframework.jms.core.JmsTemplate">
>           <property name="connectionFactory"
> ref="internalJmsQueueConnectionFactory"/>
>           <property name="destinationResolver" ref="jmsDestinationResolver"/>
>           <property name="pubSubDomain"> <value>false</value>  </property>
>           <property name="receiveTimeout"> <value>20000</value> </property>
>         </bean>
>
>     <!-- JMS Destination Resolver -->
>     <bean id="jmsDestinationResolver"
> class="org.springframework.jms.support.destination.JndiDestinationResolver">
>         <property name="jndiTemplate" ref="jndiTemplate"/>
>         <property name="cache" value="true"/>
>     </bean>
>
>   <!-- JMS Queue Connection Factory -->
>   <bean id="internalJmsQueueConnectionFactory"
> class="org.springframework.jndi.JndiObjectFactoryBean">
>         <property name="jndiTemplate" ref="jndiTemplate"/>
>     <property name="jndiName"> <value>jms/myConFactory</value>  </property>
>   </bean>
>
>   <bean id="jndiTemplate"               class="org.springframework.jndi.JndiTemplate">
>                 <property name="environment">
>                         <props><prop key="java.naming.factory.initial">
>                                         com.ibm.websphere.naming.WsnInitialContextFactory
>                                 </prop>
>                         </props>
>                 </property>
>         </bean>
> </beans>
>
>
> Thank you.
>
>
> --
> View this message in context: http://www.nabble.com/How-camel-resolve-JNDI-End-point-tf4568653s22882.html#a13039322
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


--
Regards,
Hiram

Blog: http://hiramchirino.com
Reply | Threaded
Open this post in threaded view
|

Re: How camel resolve JNDI End point

Bob G.-2
Thank you Hiram,

I will download the lates version.

Question: Was the JNDI working before in Camel? Was it the way I am using Spring JNDI it that was not working?

Thank you again.



Hiram Chirino wrote
Hi Bob,

I just committed a change so that the DestiantionResolver property is
supported on the camel JMS component.  So once you pick up that
updated.  You should be able to do the following:

<beans>
       <bean id="camel" class="org.apache.camel.spring.CamelContextFactoryBean">
               <property name="packages" value="com.abc.poc.camel.jms"/>
       </bean>

       <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
          <property name="connectionFactory"
ref="internalJmsQueueConnectionFactory"/>
          <property name="destinationResolver" ref="jmsDestinationResolver"/>
       </bean>

       
      <bean id="jmsDestinationResolver"
class="org.springframework.jms.support.destination.JndiDestinationResolver">
       <property name="jndiTemplate" ref="jndiTemplate"/>
       <property name="cache" value="true"/>
      </bean>

     
      <bean id="internalJmsQueueConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
       <property name="jndiTemplate" ref="jndiTemplate"/>
       <property name="jndiName"> <value>jms/myConFactory</value>  </property>
      </bean>

      <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
               <property name="environment">
                       <props><prop key="java.naming.factory.initial">

com.ibm.websphere.naming.WsnInitialContextFactory
                               </prop>
                       </props>
               </property>
       </bean>
</beans>

I have also made the JMS component support auto wiring the
destinationResolver property so that the above example should also
work even if you don't define the "jms" component explicitly.  But I
figure being explicit is sometimes more clear.

Please let me know if this fixes it for you.

On 10/4/07, Bob G. <aerosteak@hotmail.com> wrote:
>
> Hello
>
> I am trying to configure Camel to use JMS end point into Websphere 6.1
> (was). My end point cannot be found because of some Spring JNDI lookup
> problem.
>
> Some question :
> -  How do I tell Camel to use my Spring JndiTemplate or
> JndiDestinationResolver so that my jms queue will be resolved properly?
>
> In the documentation, it says that Camel uses Spring JmsTemplate. How can I
> tell Camel to use my JmsTemplate configured for Websphere?
>
> There is my config:
>
> <beans>
>         <bean id="camel" class="org.apache.camel.spring.CamelContextFactoryBean">
>                 <property name="packages" value="com.abc.poc.camel.jms"/>
>         </bean>
>
>
>          
>         <bean id="jmsQueueTemplate"
> class="org.springframework.jms.core.JmsTemplate">
>           <property name="connectionFactory"
> ref="internalJmsQueueConnectionFactory"/>
>           <property name="destinationResolver" ref="jmsDestinationResolver"/>
>           <property name="pubSubDomain"> <value>false</value>  </property>
>           <property name="receiveTimeout"> <value>20000</value> </property>
>         </bean>
>
>    
>     <bean id="jmsDestinationResolver"
> class="org.springframework.jms.support.destination.JndiDestinationResolver">
>         <property name="jndiTemplate" ref="jndiTemplate"/>
>         <property name="cache" value="true"/>
>     </bean>
>
>  
>   <bean id="internalJmsQueueConnectionFactory"
> class="org.springframework.jndi.JndiObjectFactoryBean">
>         <property name="jndiTemplate" ref="jndiTemplate"/>
>     <property name="jndiName"> <value>jms/myConFactory</value>  </property>
>   </bean>
>
>   <bean id="jndiTemplate"               class="org.springframework.jndi.JndiTemplate">
>                 <property name="environment">
>                         <props><prop key="java.naming.factory.initial">
>                                         com.ibm.websphere.naming.WsnInitialContextFactory
>                                 </prop>
>                         </props>
>                 </property>
>         </bean>
> </beans>
>
>
> Thank you.
>
>
> --
> View this message in context: http://www.nabble.com/How-camel-resolve-JNDI-End-point-tf4568653s22882.html#a13039322
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


--
Regards,
Hiram

Blog: http://hiramchirino.com
Reply | Threaded
Open this post in threaded view
|

Re: How camel resolve JNDI End point

jstrachan
On 05/10/2007, Bob G. <[hidden email]> wrote:
>
> Thank you Hiram,
>
> I will download the lates version.
>
> Question: Was the JNDI working before in Camel? Was it the way I am using
> Spring JNDI it that was not working?

Before Hiram's patch I don't think the JmsComponent let you specify
the DestinationResolver; to use JNDI to resolve destinations etc.

--
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com
Reply | Threaded
Open this post in threaded view
|

Re: How camel resolve JNDI End point

Hiram Chirino
On 10/5/07, James Strachan <[hidden email]> wrote:

> On 05/10/2007, Bob G. <[hidden email]> wrote:
> >
> > Thank you Hiram,
> >
> > I will download the lates version.
> >
> > Question: Was the JNDI working before in Camel? Was it the way I am using
> > Spring JNDI it that was not working?
>
> Before Hiram's patch I don't think the JmsComponent let you specify
> the DestinationResolver; to use JNDI to resolve destinations etc.
>

Correct.

> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source SOA
> http://open.iona.com
>


--
Regards,
Hiram

Blog: http://hiramchirino.com
Reply | Threaded
Open this post in threaded view
|

Re: How camel resolve JNDI End point

Bob G.-2
In reply to this post by jstrachan

Just to let you know that Camel, with the last snapshot,  works inside Websphere App Server 6.1 using the Default JMS Provider (the SIBUS).

And I am very happy about that.

Thank you again .




James.Strachan wrote
On 05/10/2007, Bob G. <aerosteak@hotmail.com> wrote:
>
> Thank you Hiram,
>
> I will download the lates version.
>
> Question: Was the JNDI working before in Camel? Was it the way I am using
> Spring JNDI it that was not working?

Before Hiram's patch I don't think the JmsComponent let you specify
the DestinationResolver; to use JNDI to resolve destinations etc.

--
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com
Reply | Threaded
Open this post in threaded view
|

Re: How camel resolve JNDI End point

jstrachan
On 05/10/2007, Bob G. <[hidden email]> wrote:
>
>
> Just to let you know that Camel, with the last snapshot,  works inside
> Websphere App Server 6.1 using the Default JMS Provider (the SIBUS).
>
> And I am very happy about that.
>
> Thank you again .

Awesome! Thanks for letting us know!
--
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com
Reply | Threaded
Open this post in threaded view
|

Re: How camel resolve JNDI End point

Bob G.-2
In reply to this post by Hiram Chirino

One last point on how Camel receive messages from JMS :

 In my other applications I use Message Driven Bean (when running in a J2EE container) or Spring MDP via the DefaultMessageListenerContainer when running in Tomcat.

- Is there a way to configure Camel to receive messages from a regular MDB?

- Does the Camel JmsComponent use the Spring DefaultMessageListenerContainer underneath ? Can I configure a recovery Interval on the JmsComponent in case of a lost connection (I know it is build-in activeMQ but not in MQ Series...)?

Thank you very much.


Hiram Chirino wrote
On 10/5/07, James Strachan <james.strachan@gmail.com> wrote:
> On 05/10/2007, Bob G. <aerosteak@hotmail.com> wrote:
> >
> > Thank you Hiram,
> >
> > I will download the lates version.
> >
> > Question: Was the JNDI working before in Camel? Was it the way I am using
> > Spring JNDI it that was not working?
>
> Before Hiram's patch I don't think the JmsComponent let you specify
> the DestinationResolver; to use JNDI to resolve destinations etc.
>

Correct.

> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source SOA
> http://open.iona.com
>


--
Regards,
Hiram

Blog: http://hiramchirino.com
Reply | Threaded
Open this post in threaded view
|

Re: How camel resolve JNDI End point

jstrachan
On 06/10/2007, Bob G. <[hidden email]> wrote:
>
>
> One last point on how Camel receive messages from JMS :
>
>  In my other applications I use Message Driven Bean (when running in a J2EE
> container) or Spring MDP via the DefaultMessageListenerContainer when
> running in Tomcat.

Under the covers we're using Spring's MessageListenerConainer stuff.

e.g.

from("activemq:My.Queue").to("file://foo/bar");


> - Is there a way to configure Camel to receive messages from a regular MDB?

If you want you can reuse MessageListenerProcessor inside some MDB
framework; but the above is gonna be eaisest

> - Does the Camel JmsComponent use the Spring DefaultMessageListenerContainer
> underneath ?

Yes

> Can I configure a recovery Interval on the JmsComponent in case
> of a lost connection (I know it is build-in activeMQ but not in MQ
> Series...)?

Yes - all the various configuration options for the various
MessageListenerContainer implementations can be configured on the
JmsComponent or the JmsEndpoint via the JmsConfiguration POJO (or the
properties on the component)

--
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com