1 Reply Latest reply on Nov 3, 2017 4:33 AM by Miroslav Novak

    WildFly10, external ArtemisMQ cluster, MDB

    Stanislav Koch Newbie

      Hello,

      I have external ArtemisMQ cluster (2 nodes). How can i configure MDB to loookup both nodes.

       

      Now i have the 2 working configurations that points to one of the nodes:

       

      Configuration #1:

       

      @MessageDriven(name = "NewItemMdb", activationConfig = { 
           @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),
           @ActivationConfigProperty(propertyName = "destination", propertyValue = "NewItem"),
           @ActivationConfigProperty(propertyName = "connectorClassName", propertyValue = "org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory"),
           @ActivationConfigProperty(propertyName = "connectionParameters", propertyValue = "host=192.168.0.86;port=61616"), //;httpUpgradeEnabled=true
           @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
           @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
      

       

      Configuration #2:

       

      @ResourceAdapter("remote-artemis-02-89")
      @MessageDriven(name = "NewItemMdb", activationConfig = { 
           @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),
           @ActivationConfigProperty(propertyName = "destination", propertyValue = "NewItem"),
           @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
           @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
      

       

          <subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
                      <remote-connector name="remote-artemis-02-89" socket-binding="remote-artemis-02-89"/>
                      <pooled-connection-factory name="remote-artemis-02-89" entries="java:/jms/remoteCF_02" connectors="remote-artemis-02-89" user="userArtemis3" password="userArtemis3"/>
          </subsystem>
      
              <outbound-socket-binding name="remote-artemis-02-89">
                  <remote-destination host="192.168.0.86" port="61616"/>
              </outbound-socket-binding>
      
        • 1. Re: WildFly10, external ArtemisMQ cluster, MDB
          Miroslav Novak Master

          Hi Stanislav,

           

          I think it's better to avoid configuring this directly in MDB and it's better to have it in standalone-full-ha.xml like:

          <subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0">
              <server name="default">
              ...
                  <remote-connector name="artemis1" socket-binding="artemis1"/>
                  <remote-connector name="artemis2" socket-binding="artemis2"/>
                  ...
                  <pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="artemis1 artemis2" transaction="xa"/>
              ...
              </server>
          </subsystem>
          
          ...
          <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
          ...
          <outbound-socket-binding name="artemis1">
              <remote-destination host="127.0.0.1" port="61616"/>
          </outbound-socket-binding>
          <outbound-socket-binding name="artemis2">
              <remote-destination host="127.0.0.1" port="62616"/>
          </outbound-socket-binding>
          </socket-binding-group>
          

           

           

          My MDB then looks like:

          import javax.ejb.ActivationConfigProperty;
          import javax.ejb.MessageDriven;
          import javax.jms.Message;
          import javax.jms.MessageListener;
          
          @MessageDriven(name = "SimpleMdb", activationConfig = {
                  @ActivationConfigProperty(propertyName = "destination", propertyValue = "InQueue"),
                  @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
                  @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")})
          public class SimpleMdb implements MessageListener {
          
              public void onMessage(Message rcvMessage) {
                  System.out.println("Received message: " + rcvMessage);
              }
          }
          

           

          connectors="artemis1 artemis2" in configuration of WF server points to acceptors of Artemis servers and will use CORE protocol. Those are just initial connectors so MDB will use one of those connectors for initial connection, load cluster topology of Artemis servers and then load balance connections. So every invocation of MDB (sessions) will be connected to different node.

           

          There is also possibility do configure discovery-group instead of connectors in pooled-connection-factory which would listen for broadcasted connectors from Artemis cluster and use it for initial connectors.

           

          Cheers,

          Mirek