Using HermesJMS with HornetQ

Version 8

    HermesJMS is a popular management console that can be used to manage many different JMS providers.

     

    For instructions on how to configure HermesJMS to manipulate JMS objects in HornetQ, please see the instructions on the Hermes JMS site.

     

    NOTE: It should be noted that the screen shot left out one Property setting for 'binding' which needs to be set to 'ContextFactory'.

    The HermesJMS wiki page mentions that "there is a plugin", which might confuse some users since no external plugins are required.

    Also, current HornetQ versions don't seem to include "hornetq-transports.jar" listed on that wiki page.

     

    Configuring HermesJMS for HornetQ standalone

     

    HermesJMS can be configured to connect to a HornetQ server using the configuration described below.

     

    This was tested with the following setup:

    • HermesJMS v1.14
    • HornetQ Server version 2.2.14.Final / standalone

     

    Here's the setup procedure:

     

    1. Create a classpath group for HornetQ in HermesJMS. Include the following JARs in the group:

    • hornetq-core-client.jar
    • hornetq-jms-client.jar
    • jnp-client.jar
    • netty.jar

     

    These JARs can be acquired from the HornetQ distribution.

     

    2. Configure a HornetQ session in HermesJMS:

     

    Connection Factory

    • Class: hermes.JNDIConnectionFactory
    • Loader: HornetQ (which was created in step 1)
    • properties
      • binding: ConnectionFactory
      • initialContextFactory: org.jnp.interfaces.NamingContextFactory
      • providerURL: jnp://localhost:1099
      • urlPkgPrefixes: org.jnp.interfaces:org.jboss.naming

     

    Please note that the procedure is different for embedded HornetQ installations with JBoss AS 7 / JBoss EAP 6 or later.

    This is because JBoss JNDI naming implementation was switched from JNP to jboss-remote-naming (see https://docs.jboss.org/author/display/AS71/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project for more information).


    Configuring HermesJMS for JBoss7 / EAP6 with HornetQ

     

    This taken mostly from Matteos remarks (thanks!) with some changes.

    PREMISES

    When you start AS7 you see in the log the RemoteConnectionFactory JNDI.

    12:47:16,653 INFO  [org.jboss.as.messaging] (pool-4-thread-2) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory

     

    You setup a JMS Queue with the following configuration:

    <jms-queue name="sample">

    <entry name="jms/queue/sample"/>

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

    </jms-queue>

     

    In summary from a REMOTE PERSPECTIVE: the RemoteConnectionFactory is on java:jboss/exported/jms/RemoteConnectionFactory, the Queue is on java:jboss/exported/jms/queue/sample

     

    Since messages are secured by default with a role guest, you have to create a user with this role:

    $JBOSS_HOME/bin/add-user.sh -s -a -u guest -p guest@123 -ro guest

     

    CONFIGURING HermesJMS

    1. Create a classpath group for HornetQ in HermesJMS
      Only one JAR is needed, is the jboss-client.jar inside the directory bin\client of the JBoss AS 7 / JBoss EAP 6 directory
      .
    2. Configure a HornetQ session in HermesJMS:
      Class: hermes.JNDIConnectionFactory
      Loader: HornetQ - the one defined in step #1
      Properties:
      binding=jms/RemoteConnectionFactory
      initialContextFactory=org.jboss.naming.remote.client.InitialContextFactory
      providerURL=remote://localhost:4447
      urlPkgPrefixes=org.jboss.naming.remote.client
      .
    3. In the Destionations of the HornetQ session which you are defining as part of step#2, Add a new Desitionation
      Name: jms/queue/sample
      Domain: QUEUE
      .
    4. Define the username/password in the "Connection" settings fields (User, Password) at the bottom of the Session Preference page of step#2


    Now in HermesJMS in the left tree structure you have your Sessions -> Your Session -> Queue which you can double-click to connect to =)Nice and Happily! You want to notice that for the binding you set the RemoteConnectionFactory without the java:jboss/exported prefix, and the same goes for the Queue defined, where from java:jboss/exported/jms/queue/sample I stripped away the java:jboss/exported prefix.


    In hermes-config.xml it looks like this:

        <classpathGroup id="JBoss_EAP_6.1">

            <library jar="my_path_to_jboss/bin/client/jboss-client.jar" noFactories="true"/>

        </classpathGroup>

     

        <factory classpathId="JBoss_EAP_6.1">

            <provider className="hermes.JNDIConnectionFactory">

                <properties>

                    <property name="binding" value="jms/RemoteConnectionFactory"/>

                    <property name="initialContextFactory" value="org.jboss.naming.remote.client.InitialContextFactory"/>

                    <property name="providerURL" value="remote://localhost:4447"/>

                    <property name="urlPkgPrefixes" value="org.jboss.naming.remote.client"/>

                </properties>

            </provider>

            <connection username="guest" password="guest@123" clientID="" connectionPerThread="false">

                <session id="JBoss" reconnects="0" transacted="true" audit="false" checkSize="false" checkSizePeriod="1000" useConsumerForQueueBrowse="false"/>

            </connection>

            <destination name="jms/queue/sample" shortName="sample" domain="1" durable="false"/>

            <extension className="hermes.ext.DefaultHermesAdminFactory">

                <properties/>

            </extension>

        </factory>

     

    Tested with:

    • HermesJMS v1.14
    • JBoss AS 7 / JBoss EAP 6, precisely JBoss EAP 6.1.0.GA