Announcement Announcement Module
Collapse
No announcement yet.
HornetQ support Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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, 07: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.

    Comment


    • #3
      configuration

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

      Code:
      <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"/>
              </bean>
          </property>
          <property name="sessionCacheSize" value="1000"/>
          <property name="cacheProducers" value="false"/>
      </bean>
      
      <bean id="requestQueue" class="org.apache.activemq.command.ActiveMQQueue">
          <constructor-arg value="queue.demo"/>
      </bean>
      
      <bean id="replyQueue" class="org.apache.activemq.command.ActiveMQQueue">
          <constructor-arg value="queue.reply"/>
      </bean>

      Comment


      • #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.

        Comment


        • #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

          Comment


          • #6
            The ActiveMQ classes in your configuration came from ActiveMQ documentation.
            For the equivalent classes for HornetQ, you should refer to either HorentQ documentation: http://www.jboss.org/hornetq/docs.html
            or HornetQ forums: http://community.jboss.org/en/hornetq?view=discussions

            Comment


            • #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

              Comment


              • #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:
                http://hornetq.sourceforge.net/docs/...x.html#d0e1189

                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.
                -Mark

                Comment


                • #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:

                  Code:
                    <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">
                            <set>
                              <bean class="org.hornetq.api.core.TransportConfiguration">
                                <constructor-arg type="java.lang.String" value="org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory"/>
                              </bean>
                            </set>
                          </property>
                          <property name="persistenceEnabled" value="true"/>
                          <property name="securityEnabled" value="false"/>
                        </bean>
                      </constructor-arg>
                    </bean>
                  
                    <bean id="hornetQJmsConfig" class="org.hornetq.jms.server.config.impl.JMSConfigurationImpl">
                      <constructor-arg index="0">
                        <list/>
                      </constructor-arg>
                      <!-- Queues -->
                      <constructor-arg index="1">
                        <list>
                          <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>
                          </bean>
                        </list>
                      </constructor-arg>
                      <!-- Topics -->
                      <constructor-arg index="2">
                        <list/>
                      </constructor-arg>
                    </bean>
                  
                    <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>
                  
                    <bean id="jmsConnectionFactory" class="org.hornetq.jms.client.HornetQConnectionFactory">
                      <constructor-arg>
                        <bean class="org.hornetq.api.core.TransportConfiguration">
                          <constructor-arg type="java.lang.String" value="org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"/>
                        </bean>
                      </constructor-arg>
                    </bean>

                  Comment


                  • #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 org.springframework.beans.factory.support.Construc torResolver.autowireConstructor(ConstructorResolve r.java:250)
                    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.autowireConstructor(Abs tractAutowireCapableBeanFactory.java:1035)
                    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:939)
                    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:485)
                    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
                    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 94)
                    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:225)
                    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:291 )
                    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:193)
                    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:585)
                    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:913)
                    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:464)
                    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:139)
                    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:83)
                    at com.fixgw.daemon.FeedDaemon.start(FeedDaemon.java: 78)
                    at com.fixgw.daemon.FeedDaemon.main(FeedDaemon.java:9 7)



                    any idea?
                    thanks,
                    ray.

                    Comment


                    • #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 factory.so 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.

                      @Configuration
                      public class JMSConfig {


                      @Value("${session.cacheSize}")
                      private Integer sessioncacheSize;

                      @Value("${cache.producers}")
                      private Boolean isCacheProducers;

                      @Value("${ems.server}")
                      private String emsServerUrls;

                      @Value("${ems.port}")
                      private String port;

                      @Value("${ems.high.available}")
                      private Boolean isHighAvailable;

                      @Value("${ems.username}")
                      private String emsUserName;

                      @Value("${ems.password}")
                      private String emsPassword;

                      @Value("${ems.transacted}")
                      private Boolean isTransacted;

                      @Value("${ems.cache.level.name}")
                      private String cacheLevelName;

                      @Value("${ems.maxconsumers}")
                      private Integer maxConsumers;

                      @Value("${ems.acknowledgment.mode}")
                      private String consumerAcknowledgementMode;

                      @Value("${ems.concurrent.consumers}")
                      private Integer concurrentConsumers;

                      @Value("${ems.broadcast.group}")
                      private String broadCastGroup;

                      @Value("${ems.broadcast.port}")
                      private Integer broadcastPort;

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


                      @PostConstruct
                      public void initilizeTransportServers() {

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

                      for (String url : splitter.split(emsServerUrls)) {
                      transportServers.add(url);

                      }

                      }

                      @Bean
                      public UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactory() {

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

                      return userCredentialsConnectionFactory;
                      }

                      @Bean
                      public CachingConnectionFactory connectionFactory() {

                      CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
                      cachingConnectionFactory.setSessionCacheSize(sessi oncacheSize);
                      cachingConnectionFactory.setCacheProducers(false);
                      cachingConnectionFactory.setCacheConsumers(false);
                      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.
                      *
                      */
                      @Bean
                      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);
                      transportConfigurations.add(server);

                      }

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

                      }


                      }


                      and SI configuration:

                      Load balencing Working:
                      <jms:message-driven-channel-adapter
                      id="limelightCatalogAdapterInboundAck"
                      channel="messageReceiverChannel"
                      cache-level="0"
                      destination-name="DLQ"
                      concurrent-consumers="${ems.concurrent.consumers}"
                      connection-factory="hornetQConnectionFactory"
                      max-concurrent-consumers="${ems.maxconsumers}" />


                      Load balencing Not working:


                      <jms:message-driven-channel-adapter
                      id="limelightCatalogAdapterInboundAck"
                      channel="messageReceiverChannel"
                      cache-level="0"
                      destination-name="DLQ"
                      concurrent-consumers="${ems.concurrent.consumers}"
                      connection-factory="userCredentialsConnectionFactory"
                      max-concurrent-consumers="${ems.maxconsumers}" />

                      Comment

                      Working...
                      X