The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Virtual Corner (2) [Avatar] Offline
#1
Hello,

I'm looking for the HornetQ Component equivalent to the ActiveMQ component that's mentioned in the book "Camel in Action" for pooling connections to HornetQ.

Am I missing something? Is messaging using Camel pretty much used with ActiveMQ and support for others are limited or non-existent?

I greatly appreciate your help,
Yuan
janstey (72) [Avatar] Offline
#2
Re: HornetQ Component
Hi Yuan,

Generally speaking, connectivity to JMS providers is done with the JMS component http://camel.apache.org/jms.html (also see chapter 7). Camel can connect to any JMS provider with this component (WebsphereMQ, Oracle AQ, WebLogic, SonicMQ, HornetQ, etc). Now in the case of ActiveMQ, they provide a JMS component with ActiveMQ-specific enhancements like connection pooling turned on by default

http://svn.apache.org/repos/asf/activemq/trunk/activemq-camel/

I'm not aware of any specialized Camel JMS component shipped with HornetQ. You should be able to do this with a bit of extra configuration though.

Let me know if you need more info.

Cheers,
Jon
Virtual Corner (2) [Avatar] Offline
#3
Re: HornetQ Component
Thanks, Jon, for the quick response.

Can you point me to a source (in the book or elsewhere) where I can learn more about the "extra configuration" to create a HornetQ component for connection pooling?

Thanks again,
Yuan
janstey (72) [Avatar] Offline
#4
Re: HornetQ Component
So to configure the plain JMS component to connect to any JMS provider, you just need to set the connection factory. For example, we could not use the camel-activemq component and just configure the JMS component as follows:

<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
</bean>
</property>
</bean>

For HornetQ its probably something like this

<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory">
<bean class="org.hornetq.jms.client.HornetQConnectionFactory">
...
</bean>
</property>
</bean>

You should be able to set some option on the HornetQConnectionFactory to enable pooling... Now, I've never used HornetQ before so I don't know how to set up connection pooling for it...

Also, for reference in ActiveMQ the pooling ConnectionFactory is org.apache.activemq.pool.PooledConnectionFactory

Hope this helps.

Cheers,
Jon
davsclaus (413) [Avatar] Offline
#5
Re: HornetQ Component
And a little google showed that someone wrote a camel-hornetmq component and posted a blog about that
http://diego-pacheco.blogspot.com/2010/02/jboss-hornetq-component-for-apache_23.html
chris.wolf (1) [Avatar] Offline
#6
Re: HornetQ Component
I think it's a mistake to use a JMS provider-specific component. The whole point of JMS (like JDBC) is to use the public API irrespective of the particular implementation provider. I use HornetQ just with the "jms:" component. The fragment of my Spring DSL looks like:

(N.B. this was properly formatted and indented before posting into this rudimentary forum software)

<bean id="connectionFactory" class="demo.spring.jms.CachingIfJBossNotRunningConnectionFactory" >
p:asConnectionFactoryName="java:/JmsXA" p:saConnectionFactoryName="/ConnectionFactory">
<property name="defaultEnvironment">
<description><![CDATA[ >
These JNDI settings are used only when running Maven's embedded Camel client,
such as when generating site docs via "mvn site" or "mvn camel:dot".

Normally, the JNDI environment is generated by:
JavaNamingProviderConfig.getJavaNamingProviderProperties() (i.e. from JBossAS)

Otherwise, Unit Tests load from "classpath:/demo/test/hornetq/jndi.properties"
]]></description>
<props>
<prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
<prop key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop>
<prop key="java.naming.provider.url">localhost:1099</prop>
</props>
</property>
</bean>
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="connectionFactory"/>
</bean>