1 Reply Latest reply on Nov 5, 2012 12:07 AM by jbertram

    Please help the newbee

    gary002g

      It is probably something very basic but I have wasted the whole day and cannot figure it out.

      I am testing my code (Web application running on Jetty) which at some point suppose to send a message to the queue.

      I have HornetQ (2.2.14final) installed on my laptop (localhost) and it is running with default settings as a standalone server.

       

      The code is simple:

      public class RequestQueueManager {

          private static final int MAX_MASK = 0x80;

       

       

          private ConnectionFactory factory;

          private Queue queue;

       

       

          public RequestQueueManager(ConnectionFactory factory, Queue queue) {

              this.factory = factory;

              this.queue = queue;

          }

       

       

          public void enqueueRequest(String requestId, int priority, int mask) throws JMSException {

              JmsTemplate sender = new JmsTemplate(factory);

              sender.setDefaultDestination(queue);

              sender.setPriority(priority);

              sender.send(new RequestMessageCreator(requestId, mask));

          }

      }

      and my Spring context looks like

          <bean id="queueConfiguration" class="org.hornetq.api.core.DiscoveryGroupConfiguration">
              <constructor-arg value="${Queue.Host}"/>
              <constructor-arg value="${Queue.Port}"/>
          </bean>
      
      
          <bean id="connFactory" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
              <property name="staticMethod" value="org.hornetq.api.jms.HornetQJMSClient.createConnectionFactoryWithoutHA"/>
              <property name="arguments">
                  <list>
                      <ref local="queueConfiguration"/>
                      <util:constant static-field="org.hornetq.api.jms.JMSFactoryType.QUEUE_CF"/>
                  </list>
              </property>
          </bean>
      
      
          <bean id="requestQueue" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
              <property name="staticMethod" value="org.hornetq.api.jms.HornetQJMSClient.createQueue"/>
              <property name="arguments">
                  <list>
                      <value>${Queue.Name}</value>
                  </list>
              </property>
          </bean>
      
      
          <bean id="queueManager" class="com.cydesign.queue.RequestQueueManager">
              <constructor-arg ref="jmsConnectionFactory"/>
              <constructor-arg ref="requestQueue"/>
          </bean>
      
      
          <bean id="jmsConnectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
              <constructor-arg ref="connFactory"/>
          </bean>
      

       

      I am getting the following exception:

       

      Nov 4, 2012 6:43:55 PM org.hornetq.core.logging.impl.JULLogDelegate error
      SEVERE: Failed to create discovery group socket
      java.net.SocketException: Not a multicast address
                at java.net.MulticastSocket.joinGroup(MulticastSocket.java:304)
                at org.hornetq.core.cluster.impl.DiscoveryGroupImpl.start(DiscoveryGroupImpl.java:152)
                at org.hornetq.core.client.impl.ServerLocatorImpl.initialise(ServerLocatorImpl.java:370)
                at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:706)
                at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601)
                at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:119)
                at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:114)
                at org.springframework.jms.connection.SingleConnectionFactory.doCreateConnection(SingleConnectionFactory.java:342)
                at org.springframework.jms.connection.SingleConnectionFactory.initConnection(SingleConnectionFactory.java:288)
                at org.springframework.jms.connection.SingleConnectionFactory.createConnection(SingleConnectionFactory.java:225)
                at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
                at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:456)
                at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:534)
                at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:526)
                at com.cydesign.queue.RequestQueueManager.enqueueRequest(RequestQueueManager.java:54)
                at com.cydesign.service.RequestValidator.enqueueRequest(RequestValidator.java:224)
                at com.cydesign.service.RequestValidator.run(RequestValidator.java:72)
                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
                at java.lang.Thread.run(Thread.java:680)
      
      

      If some kind soul can tell me what is wrong with my either code or config file, I'll appreciate it greatly.

        • 1. Re: Please help the newbee
          jbertram

          You're using a org.hornetq.api.core.DiscoveryGroupConfiguration which is meant for UDP multicast server discovery with a non-multicast address (as the error message indicates).  You should either specify a multicast address and port for the org.hornetq.api.core.DiscoveryGroupConfiguration or use a different class (e.g. org.hornetq.api.core.TransportConfiguration).