Announcement Announcement Module
No announcement yet.
HornetQ support Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • HornetQ support

    can someone post how to use HorentQ with Spring integration?
    I used ActiveMQ but due to its fatal bug i was forced to try something else. i wish to try the new HornetQ but i can't seem to find any documentation on how to configure my spring configuration files.
    help please...
    Last edited by avibh; Feb 8th, 2010, 06:36 AM.

  • #2
    SI JMS integration is not specific to any messaging system. In fact it uses Spring JMS behind the scenes.
    I would be surprised if you had to change anything other then the ConnectionFactory configuration in your SI/Spring configuration.
    However, if you have a more specific question, please let us know.


    • #3

      heres my current ActiveMQ configuration, can you tell me what needs to go instead of each ActiveMQ section?

      <bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
          <property name="targetConnectionFactory">
              <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                  <property name="brokerURL" value="tcp://avibh-laptop:61616"/>
          <property name="sessionCacheSize" value="1000"/>
          <property name="cacheProducers" value="false"/>
      <bean id="requestQueue" class="org.apache.activemq.command.ActiveMQQueue">
          <constructor-arg value="queue.demo"/>
      <bean id="replyQueue" class="org.apache.activemq.command.ActiveMQQueue">
          <constructor-arg value="queue.reply"/>


      • #4
        You should refer to HornetQ documentation for Destination and Connection Factory configuration. There is nothing spring specific asyou can see from your own config. However, since you are using HornetQ, you are probably running in JBoss and your messaging system is JNDI configured, so all you need is look up your destinations and connection factory via <jee:jndi-lookup ...> element.


        • #5
          i want to use HornetQ as a stand alone application, not inside jboss.
          there is no spring integration specific code there, but there is ActiveMQ specific code there and i need to know the correct equivalents for HornetQ, if any


          • #6
            The ActiveMQ classes in your configuration came from ActiveMQ documentation.
            For the equivalent classes for HornetQ, you should refer to either HorentQ documentation:
            or HornetQ forums:


            • #7
              actually it came from the SI examples bundled in version 2.0m2 but lets not be picky :-)
              I will try my luck on the HorentQ forum, thanks


              • #8
                Our sample application just happens to *use* ActiveMQ as a JMS provider, but as Oleg mentioned, the actual dependencies from Spring Integration's perspective are defined in the JMS API itself (ConnectionFactory and Queue in this case).

                Here's a link to the section of documentation that HornetQ provides for "standalone" configuration:

                They use factory methods and utility classes, so you would likely need to use Spring's "factory-method" attribute in an XML based configuration.

                Hope that helps.


                • #9
                  Sorry for posting to this old thread, but for future searchers, here is a simple working Spring configuration for HornetQ outside of JBoss, and without using JNDI:

                    <bean id="hornetQServer" class="org.hornetq.core.server.impl.HornetQServerImpl">
                      <constructor-arg type="org.hornetq.core.config.Configuration">
                        <bean class="org.hornetq.core.config.impl.ConfigurationImpl">
                          <property name="acceptorConfigurations">
                              <bean class="org.hornetq.api.core.TransportConfiguration">
                                <constructor-arg type="java.lang.String" value="org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory"/>
                          <property name="persistenceEnabled" value="true"/>
                          <property name="securityEnabled" value="false"/>
                    <bean id="hornetQJmsConfig" class="org.hornetq.jms.server.config.impl.JMSConfigurationImpl">
                      <constructor-arg index="0">
                      <!-- Queues -->
                      <constructor-arg index="1">
                          <bean class="org.hornetq.jms.server.config.impl.JMSQueueConfigurationImpl">
                            <!-- Name -->
                            <constructor-arg index="0" value="testqueue"/>
                            <!-- Selector -->
                            <constructor-arg index="1"><null/></constructor-arg>
                            <!-- Durable queue -->
                            <constructor-arg index="2" value="true"/>
                            <!-- JNDI bindings, empty list for none -->
                            <constructor-arg index="3"><list/></constructor-arg>
                      <!-- Topics -->
                      <constructor-arg index="2">
                    <bean name="hornetQJmsServer" class="org.hornetq.jms.server.impl.JMSServerManagerImpl" init-method="start" destroy-method="stop">
                      <constructor-arg index="0" ref="hornetQServer"/>
                      <constructor-arg index="1" ref="hornetQJmsConfig"/>
                    <bean id="jmsConnectionFactory" class="org.hornetq.jms.client.HornetQConnectionFactory">
                        <bean class="org.hornetq.api.core.TransportConfiguration">
                          <constructor-arg type="java.lang.String" value="org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"/>


                  • #10
                    Hi rgupta,

                    I tried your configuration and I got this error:

                    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'hornetQJmsConfig' defined in class path resource [applicationContext.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
                    at torResolver.autowireConstructor(ConstructorResolve
                    at AutowireCapableBeanFactory.autowireConstructor(Abs
                    at AutowireCapableBeanFactory.createBeanInstance(Abst
                    at AutowireCapableBeanFactory.doCreateBean(AbstractAu
                    at AutowireCapableBeanFactory.createBean(AbstractAuto
                    at BeanFactory$1.getObject( 94)
                    at ingletonBeanRegistry.getSingleton(DefaultSingleton
                    at BeanFactory.doGetBean( )
                    at BeanFactory.getBean(
                    at istableBeanFactory.preInstantiateSingletons(Defaul
                    at ationContext.finishBeanFactoryInitialization(Abstr
                    at ationContext.refresh(AbstractApplicationContext.ja va:464)
                    at plicationContext.<init>(ClassPathXmlApplicationCon
                    at plicationContext.<init>(ClassPathXmlApplicationCon
                    at com.fixgw.daemon.FeedDaemon.start( 78)
                    at com.fixgw.daemon.FeedDaemon.main( 7)

                    any idea?


                    • #11
                      Hi, I am facing a problem in spring hornetq integration.The hornetq is running in a two node cluster mode.My requirement is jms session load balancing to hornetq nodes.i configured a spring integration consumer (message driven channel adapter) to connect to hornetq through spring caching connection if i configure concurrent consumers as 10,5 consumers should be connected to node 1 and 5 consumers should connect to node2.But the behaviour is all 10 consumers is get attached to one hornetq node only.
                      If we remove spring caching connection factory from spring integration message driven channel adapter and attcah hornetq conenction fcatory ,the load balencing is working fine.Also i tried to use diffrent cache levels like 0,1,2,3.the laod balencing is not at all working with a spring caching conenction factory.How will we solve this problem.if i remove spring ccahing conenction fcatory the performance seems drastically reduced.

                      My configuration is as below.

                      public class JMSConfig {

                      private Integer sessioncacheSize;

                      private Boolean isCacheProducers;

                      private String emsServerUrls;

                      private String port;

                      private Boolean isHighAvailable;

                      private String emsUserName;

                      private String emsPassword;

                      private Boolean isTransacted;

                      private String cacheLevelName;

                      private Integer maxConsumers;

                      private String consumerAcknowledgementMode;

                      private Integer concurrentConsumers;

                      private String broadCastGroup;

                      private Integer broadcastPort;

                      private List<String> transportServers = Lists.newArrayList();

                      public void initilizeTransportServers() {

                      Splitter splitter = Splitter.on(DELEMITER_COMMA).omitEmptyStrings().tr imResults();

                      for (String url : splitter.split(emsServerUrls)) {



                      public UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactory() {

                      UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactory = new UserCredentialsConnectionFactoryAdapter();
                      userCredentialsConnectionFactory.setTargetConnecti onFactory(connectionFactory());
                      userCredentialsConnectionFactory.setUsername(emsUs erName);
                      userCredentialsConnectionFactory.setPassword(emsPa ssword);

                      return userCredentialsConnectionFactory;

                      public CachingConnectionFactory connectionFactory() {

                      CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
                      cachingConnectionFactory.setSessionCacheSize(sessi oncacheSize);
                      cachingConnectionFactory.setTargetConnectionFactor y(hornetQConnectionFactory());

                      return cachingConnectionFactory;

                      * Direct Connection factory use is recommended for client side load balancing as HA JNDI is complex and
                      * requires configuration in messaging system.JNDI server can be completely avoided with direct connection factory usage.
                      * also provides additional flexibility to add interceptor for logging and monitoring ,and perform better than HA JNDI.
                      public ConnectionFactory hornetQConnectionFactory() {
                      TransportConfiguration[] transportConfigurations = transportConfiguration();
                      //DiscoveryGroupConfiguration groupConfiguration = new DiscoveryGroupConfiguration(broadCastGroup, broadcastPort);
                      //groupConfiguration.setDiscoveryInitialWaitTimeout( 3000);

                      //ConnectionFactory connectionFactory = (ConnectionFactory) HornetQJMSClient.createConnectionFactoryWithHA(JMS FactoryType.QUEUE_CF,transportConfigurations);

                      HornetQJMSConnectionFactory connectionFactory = new HornetQJMSConnectionFactory(Boolean.FALSE, transportConfigurations);
                      return connectionFactory;

                      public TransportConfiguration[] transportConfiguration() {

                      List<TransportConfiguration> transportConfigurations = Lists.newArrayList();

                      for (String url : transportServers) {

                      Map<String, Object> map = Maps.newHashMap();
                      map.put(EMS_HOST, url);
                      map.put(EMS_PORT, port);

                      TransportConfiguration server = new TransportConfiguration(NettyConnectorFactory.class .getName(), map);


                      return transportConfigurations.toArray(new TransportConfiguration[transportConfigurations.size()]);



                      and SI configuration:

                      Load balencing Working:
                      max-concurrent-consumers="${ems.maxconsumers}" />

                      Load balencing Not working:

                      max-concurrent-consumers="${ems.maxconsumers}" />