3 Replies Latest reply on Aug 22, 2014 11:25 AM by jbertram

    jboss eap 6.2 jndi name to remote hornetq

    kts92tln8

      hornetq server running without JMS and JNDI server in its own JVM (localhost:5445). Jboss EAP 6.2 standalone running in its own JVM, there are no acceptors running in jboss server.

       

      I've added a q in hornetq server config

       

          <queues>

            <queue name="HQ.SELECTORQ">

              <address>HQ.SELECTORQ</address>

              <durable>true</durable>

            </queue>

          </queues>

       

      in jboss config using hornetq-ra pooled-connection-factory to connect to hornetq server, following is from standalone-full.xml

       

              <subsystem xmlns="urn:jboss:domain:messaging:1.4">

                  <hornetq-server>

                      <persistence-enabled>true</persistence-enabled>

                      <journal-type>NIO</journal-type>

                      <journal-min-files>2</journal-min-files>

       

                      <connectors>

                          <netty-connector name="netty" socket-binding="messaging"/>

                          <netty-connector name="netty-throughput" socket-binding="messaging-throughput">

                              <param key="batch-delay" value="50"/>

                          </netty-connector>

                          <netty-connector name="netty-remote" socket-binding="messaging">

                              <param key="host" value="localhost"/>

                              <param key="port" value="5445"/>

                          </netty-connector>

                          <in-vm-connector name="in-vm" server-id="0"/>

                      </connectors>

       

                      <security-settings>

                          <security-setting match="#">

                              <permission type="send" roles="guest"/>

                              <permission type="consume" roles="guest"/>

                              <permission type="createNonDurableQueue" roles="guest"/>

                              <permission type="deleteNonDurableQueue" roles="guest"/>

                          </security-setting>

                      </security-settings>

       

                      <address-settings>

                          <address-setting match="#">

                              <dead-letter-address>jms.queue.DLQ</dead-letter-address>

                              <expiry-address>jms.queue.ExpiryQueue</expiry-address>

                              <redelivery-delay>0</redelivery-delay>

                              <max-size-bytes>10485760</max-size-bytes>

                              <page-size-bytes>2097152</page-size-bytes>

                              <address-full-policy>PAGE</address-full-policy>

                              <message-counter-history-day-limit>10</message-counter-history-day-limit>

                          </address-setting>

                      </address-settings>

       

                      <jms-connection-factories>

                          <connection-factory name="InVmConnectionFactory">

                              <connectors>

                                  <connector-ref connector-name="in-vm"/>

                              </connectors>

                              <entries>

                                  <entry name="java:/ConnectionFactory"/>

                              </entries>

                          </connection-factory>

                          <connection-factory name="RemoteConnectionFactory">

                              <connectors>

                                  <connector-ref connector-name="netty"/>

                              </connectors>

                              <entries>

                                  <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>

                              </entries>

                          </connection-factory>

                          <pooled-connection-factory name="hornetq-ra">

                              <transaction mode="xa"/>

                              <connectors>

                                  <connector-ref connector-name="netty-remote"/>

                              </connectors>

                              <entries>

                                  <entry name="java:/JmsXA"/>

                              </entries>

                              <ha>true</ha>

                              <client-failure-check-period>10</client-failure-check-period>

                              <retry-interval>1000</retry-interval>

                              <retry-interval-multiplier>1.0</retry-interval-multiplier>

                              <max-retry-interval>60000</max-retry-interval>

                              <reconnect-attempts>1000</reconnect-attempts>

                          </pooled-connection-factory>

                      </jms-connection-factories>

                  </hornetq-server>

              </subsystem>

       

      an EJB running in jboss server is trying to put msg on queue in hornetq server (HQ.SELECTORQ) using JMS and JNDI. I could use 'java:/JmsXA' connectionfactory,

      however I couldnot figure how to define a jndi name for HQ.SELECTORQ queue in jboss config.

       

      following is my code trying toi put msg on the queue that is invoked by an ejb running in jboss server

       

      Context ctx = new InitialContext();

      ConnectionFactory cf = (ConnectionFactory) ctx.lookup(connectionFactoryJndi);

      dest = (Destination) ctx.lookup("what jndi name should go here ???");

      con = cf.createConnection();

      session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);

      producer = session.createProducer(dest);

      tmsg = session.createTextMessage(msg);

      producer.send(tmsg);

       

       

      If there is any documentation and notes I need to look please point me to it.

       

      Thanks.

        • 1. Re: jboss eap 6.2 jndi name to remote hornetq
          jbertram

          Typically a JMS destination is looked up from JNDI on the server that's actually hosting it.  However, this isn't strictly necessary as the destination stub doesn't contain anything special linking it to the server from which it was looked up.  In your case, you have 3 options that I can see:

           

          1. Define the JMS queue locally on your EAP server and look that up.
          2. Use javax.jms.Session.createQueue(String) to programmatically instantiate the destination.
          3. Use org.hornetq.api.jms.HornetQJMSClient.createQueue(String) to programmatically instantiate the destination.
          • 2. Re: jboss eap 6.2 jndi name to remote hornetq
            kts92tln8

            Thanks for the reply.

             

            if I use option 1, queues will still be hosted at remote hornetq server ?

             

            I tried option 2, I'm getting following exception in jboss server logs

             

              Exception in thread "main" javax.jms.JMSException: There is no queue with name HQ.SELECTORQ

                at org.hornetq.jms.client.HornetQSession.createQueue(HornetQSession.java:402)

                at org.hornetq.ra.HornetQRASession.createQueue(HornetQRASession.java:860)

                at ds.test.ejb.EchoBean.putMsg(EchoBean.java:95)

             

            following is my code

             

                      ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:/JmsXA");

                      con = cf.createConnection();

                      session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);

                      dest = session.createQueue("HQ.SELECTORQ");

                      producer = session.createProducer(dest);

                      tmsg = session.createTextMessage(msg);

                      producer.send(tmsg);

             

            also

             

            - what we are doing not hosting jndi in hornetq server and using jboss jndi server to provide jndi name which points to hornetq core queues, is any better/worst then hosting jndi/jms server in hornetq server ? we could have jndi/jms server running in hornetq server too, but we are making assumption (without any basis) that running minimal hornetq server would be better and jndi/jms is part of jboss anyways.

             

            - would it still be possible to run mdb in remote jboss server without having jndi names in hornetq server.

             

            please comment.

             

            Thanks for your help, much appreciated.

            • 3. Re: jboss eap 6.2 jndi name to remote hornetq
              jbertram

              if I use option 1, queues will still be hosted at remote hornetq server ?

              Yes, the remote HornetQ server would still host the queues themselves, but your local EAP server would have a jms-queue defined with the necessary JNDI entry for local client lookup.  Note, the jms-queue would need to have the same name as the remote queue.

               

              what we are doing not hosting jndi in hornetq server and using jboss jndi server to provide jndi name which points to hornetq core queues, is any better/worst then hosting jndi/jms server in hornetq server ? we could have jndi/jms server running in hornetq server too, but we are making assumption (without any basis) that running minimal hornetq server would be better and jndi/jms is part of jboss anyways.

              As you probably know, making assumptions in software development is usually a bad idea.  I would say that you're not buying yourself much in this situation.  JMS is a pretty thin layer on top of HornetQ core.

              1 of 1 people found this helpful