9 Replies Latest reply on Jun 5, 2014 9:43 AM by jbertram

    HornetQ Rest support in JBoss AS 7

    abendt

      hi all,

       

      i'm trying to setup HornetQ REST support in JBoss AS 7 (v7.1.1 or 7.1.3).

       

      looking at the boot log i can see that AS 7.1.1 uses HornetQ v2.2.13.Final. Unfortunately there is no documentation for that version available here: http://www.jboss.org/hornetq/docs

       

      REST related documentation for other versions can be found here Single HTML page (v2.3.0.Alpha) or here Single HTML page (v2.2.2.Final). Both documents reference the hornetq-rest jar. Unfortunately there's no matching version available in the maven repo (http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.hornetq.rest%22%20AND%20a%3A%22hornetq-rest%22) or (https://repository.jboss.org/nexus/index.html#nexus-search;quick~hornetq-rest).

       

      Is REST supported in JBoss AS 7? Is anyone using it successfully?

       

      best regards,

          Alphonse Bendt

        • 1. Re: HornetQ Rest support in JBoss AS 7
          jbertram

          I'm not exactly sure what you mean by "supported."  You are using a community distribution which isn't supported with any kind of SLA.

           

          In any case, you can pull the source for 2.2.13 and build the hornetq-rest module to get the hornetq-rest.jar as well as the documentation.  I can't remember in which version it was added, but there are specific instructions regarding setting up HornetQ REST in AS 7.

          1 of 1 people found this helpful
          • 2. Re: HornetQ Rest support in JBoss AS 7
            abendt

            thanks.

             

            I'm aware that this is a community distribution. What i meant to ask is "does it work"

            • 3. Re: HornetQ Rest support in JBoss AS 7
              jbertram

              What i meant to ask is "does it work"

              Yes.  It should work.

               

              Another option is to move to an AS7 nightly build which uses 2.3.0.Beta1 which, to my knowledge, has all the aforementioned resources.

              • 4. Re: HornetQ Rest support in JBoss AS 7
                rogergwyatt

                I had quite a struggle getting this to work because the documentation is wrong. Here is what works with Jboss 7.1.1.Final:

                 

                1) Turn on HornetQ in the your configuration xml (standalone.xml, or whatever version you use). You can define your queues there or use the admin console.

                2) Create a .WAR file with the following:

                    a. a jboss-deployment-structure.xml in /META_INF with the dependencies for "org.hornetq" and "org.jboss.netty" (this is where the documentation is wrong. Adding the dependency in the manifest.mf file does not work. It needs to be in the jboss-deployment-structure.xml file.

                    b. put the hornetq-rest.______.jar ( _____ is the version number you are using).

                    c. create a web.xml that looks like this:

                <web-app  version="3.0"

                xmlns="http://java.sun.com/xml/ns/javaee"

                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

                    <listener>

                        <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>

                    </listener>

                    <listener>

                        <listener-class>org.hornetq.rest.integration.RestMessagingBootstrapListener</listener-class>

                    </listener>

                    <filter>

                        <filter-name>Rest-Messaging</filter-name>

                        <filter-class>

                            org.jboss.resteasy.plugins.server.servlet.FilterDispatcher

                        </filter-class>

                    </filter>

                    <filter-mapping>

                        <filter-name>Rest-Messaging</filter-name>

                        <url-pattern>/*</url-pattern>

                    </filter-mapping>

                </web-app>

                3. deploy your .WAR file.

                4. you will access your queues using the following naming scheme:

                     http://servername:8080/warfilename/queues/jms._______

                NOTE: even though you access your queues using the warfilename for the restful connections, you will still be able to use the management console without the warfilename.

                 

                So, the problem with the documentation is that you need a jboss-deployment-structure.xml rather than the manifest.mf for the dependencies. Also, it is easy to miss that you will be using the warfilename in the url.

                 

                Hope this saves people some headaches.

                • 5. Re: Re: HornetQ Rest support in JBoss AS 7
                  jbertram

                  So, the problem with the documentation is that you need a jboss-deployment-structure.xml rather than the manifest.mf for the dependencies. Also, it is easy to miss that you will be using the warfilename in the url.

                  Just to set the record straight, I just tried the instructions from the documentation on a fresh installation of JBoss AS 7.1.1.  I did not, in fact, need a jboss-deployment-structure.xml file.  The dependency declaration in MANIFEST.MF was sufficient. It's not clear to me what you might have been doing wrong with the manifest which would have required you to use the jboss-deployment-structure.xml alternative.

                   

                  Furthermore, the documentation states:

                  It is worth noting that when deploying a WAR in a Java EE application server like AS7 the URL for the resulting application will include the name of the WAR by default. For example, if you've constructed a WAR as described above named "hornetq-rest.war" then clients will access it at, e.g. http://localhost:8080/hornetq-rest/[queues|topics]. We'll see more about this later.

                  Then later the documentation says:

                  The base of the URI is the base URL of the WAR you deployed the HornetQ REST server within as defined in the Installation and Configuration section of this document.

                  As for the examples which use "http://example.com/" without the apparent use of the WAR name, this is done as an example assuming that in production the WAR would be installed at the "root context" of the server.  As the documentation states:

                  It is possible to put the WAR file at the "root context" of AS7, but that is beyond the scope of this documentation.

                  • 6. Re: Re: HornetQ Rest support in JBoss AS 7
                    rogergwyatt

                    Perhaps it is the type of project created that made the difference. I use Eclipse and created a plain Java project. I had my dependencies in the manifest.mf exactly like the documentation and it would not connect. I had to add them in a jboss-deployment-structure.xml file.

                     

                    I wasn't complaining about needing the .war name - that's the way it works normally. It's just that some of the important points are in the middle of a paragraph between two blocks. It makes it easy to miss.

                    • 7. Re: Re: HornetQ Rest support in JBoss AS 7
                      jbertram

                      I don't use Eclipse.  I just created the WAR manually (just like I did when I wrote the documentation).  Using the manifest for dependency declaration is a documented feature of JBoss AS 7.  Not sure what could be going wrong in your case.

                      • 8. Re: Re: HornetQ Rest support in JBoss AS 7
                        rogergwyatt

                        I'm also not sure why it wasn't working using the manifest. It should have, I agree. The reason for my post was because I look everywhere for a solution and meticulously followed the documentation with no success. When I remembered that I could use the jboss-deployment-structure.xml to set dependencies and went that route then it worked for me. I wanted to document the solution for others who were having the same issue.

                        • 9. Re: Re: HornetQ Rest support in JBoss AS 7
                          jbertram

                          Can you post your full jboss-deployment-structure.xml?  I'll add that option to the documentation.