3 Replies Latest reply on Mar 31, 2014 1:51 PM by jaxtonlee

    Running 2 HornetQ Servers on Laptop

    jaxtonlee

      Hey guys,

       

      So on my laptop here (Mac OS X 10.8), I'm trying to get 2 JBoss AS7 servers running side-by-side.  I generally followed the instructions outlined in this discussion, but let me provide some background and my current configuration:

       

      The first JBoss instance is meant to be the sole receiver of JMS messages (via MDB's).  I'll call this one the "JMS receiver JBoss", and it's mapped to 127.0.0.1.  On this instance, the application can also send messages to the local queues/topics.

      The second JBoss instance is meant to send JMS messages, but should not receive anything.  I'll call this one the "JMS client JBoss", and it's mapped to 127.0.0.2.  In other words, all of the messages the application sends should be received by the first instance.

       

      Now here's the challenge:  I'd like the same application code-base (WAR file) to be on both instances.  I am able to start up both JBoss instances okay with the same WAR file, but when a JMS message gets sent by either of the instances, I'm seeing an interesting phenomenon:  Sometimes a message gets received by the first instance, and sometimes a message gets received by the second instance.  It seems non-deterministic which messages go where.  Digging a bit further, I started the JBoss Admin console for each of the instances; bringing up the JMS Destinations section, I can verify that the only HornetQ instance that the messages are added to is the one on the JMS receiver JBoss.  So that's good.  So the problem appears to be that the MDB's on the JMS client JBoss are still somehow connecting to the remote queue, when in fact I don't want them to.  Reading through some of the HornetQ documentation, I think there's a "connectionParameters" activation config property, and that the default value for the host is "localhost" ?  If that's the case, then maybe since localhost maps to 127.0.0.1 (in the /etc/hosts file), the MDB's on the JMS client JBoss would still be connecting to the remote HornetQ?  Total guess there.  I'm a bit unclear on which inbound resource adapter the MDB's use exactly.  I've seen examples of people re-configuring HornetQ's inbound adapter, but they tend to be with standalone HornetQ servers (with an .rar file) rather than ones embedded in JBoss AS7.  Again, the fact that I want both JBoss instances to have the same WAR file makes this more complicated (it's because our code-base isn't modular enough to support that model yet).

       

      Anyway, it's probably impossible to know what I'm talking about without the configuration files, so I attached them both to this message.  Also, here's an example of the annotations for one of my MDB's which exhibits this strange dual receiving phenomenon.

       

      @MessageDriven(mappedName = "queue/SchoolSync", activationConfig = {

        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),

        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),

        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/SchoolSync"),

        @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "4")

      })

      public class SyncSchoolListener implements MessageListener {

       

       

      Of course, before running the JMS client JBoss, I issue this:

       

      sudo ifconfig lo0 alias 127.0.0.2

       

      And to start the JMS client JBoss, I issue this:

       

      ./standalone.sh -Djboss.home.dir=/Users/jeffreyleeman/jboss/jboss-2-as-7.1.1.Final

       

      Thanks in advance for any help anyone can offer!

       

      ~ Jaxton

        • 1. Re: Running 2 HornetQ Servers on Laptop
          ataylor

          moved to correct forum

          • 2. Re: Running 2 HornetQ Servers on Laptop
            ataylor

            so what is happening is that you are deploying MDB's on your client jboss that will consume from the receiver jboss, the simplest solution would be to not deploy them, you say you want to deploy the same war on both, is there a reason for this.

             

            the configuration of the MDB's come from the 'hornerq-ra' pooled connection factory (this is the default that MDB's use), on the client this uses 127.0.0.1 which is why your MDB's are listening to the receiver jboss, Im assuming you are using this factory for sending your messages? if you are you could just set the pooled connection factory back to use the invm connector and create another one to use for sending messages.

             

            also make sure each instance is using its own journal, looks like you are using the defaults for both.

            • 3. Re: Running 2 HornetQ Servers on Laptop
              jaxtonlee

              Thanks a lot Andy!  Your recommendation worked like a charm.  So for the record, here's the set of pooled-connection-factories that I configured on the 'JMS client JBoss' :

               

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

                  <transaction mode="xa"/>

                  <connectors>

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

                  </connectors>

                  <entries>

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

                  </entries>

              </pooled-connection-factory>

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

                  <transaction mode="xa"/>

                  <connectors>

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

                  </connectors>

                  <entries>

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

                  </entries>

              </pooled-connection-factory>

               

              And everything is received by only the "JMS Receiver JBoss".  I guess my problem here was just an artifact of having two JBoss instances on a single host (localhost); in an environment with multiple VM's, that additional "sender-hornetq-ra" pooled-connection-factory wouldn't be necessary I'm guessing.

               

              To answer your question about the WAR packaging, we would like to get to a point where different WAR's would get deployed to different VM's (one version with MDB's, and one without), but our build/deployment process just isn't there yet.  It also might be beneficial to have the MDB's on the different VM's, for fail-over scenarios.

               

              Thanks again,

               

              ~ Jaxton