10 Replies Latest reply on Feb 25, 2017 11:28 AM by George tsobis

    wildfly-10.1.0.Final multiple artemis servers

    George tsobis Newbie

      Hello,

      When using wildfly-10.1.0.Final is it possible to use multiple artemis servers for messaging? The server includes an embedded version (1.1.0) of the artemis server which I am using for internal communications. However, I was wondering if I can use an external standalone version (1.5.3) of artemis alongside the embedded one.

      If yes what do I need to change?

      Do I need create the ra as a module? (will this create a problem (conflicts) with the already created module?)

      On the standalone-full.xml I need to create a resource-adapter what about the urn:jboss:domain:ejb3:4.0 subsystem, what can I do to keep the mdb and reference one for the external server

       

      Thanks in advance

      Tsobis George

        • 1. Re: wildfly-10.1.0.Final multiple artemis servers
          Justin Bertram Master

          When using wildfly-10.1.0.Final is it possible to use multiple artemis servers for messaging? The server includes an embedded version (1.1.0) of the artemis server which I am using for internal communications. However, I was wondering if I can use an external standalone version (1.5.3) of artemis alongside the embedded one.

          If yes what do I need to change?

          Yes, you can run multiple instances and versions of Artemis on a single physical machine granted they are either listening on different network interfaces or if they use the same network interface but different ports.

           

          Do I need create the ra as a module? (will this create a problem (conflicts) with the already created module?)

          On the standalone-full.xml I need to create a resource-adapter what about the urn:jboss:domain:ejb3:4.0 subsystem, what can I do to keep the mdb and reference one for the external server

          What exactly are your functional requirements?  If you need for a producer or MDB consumer to connect from Wildfly to the new instance of Artemis then simply configure a new pooled-connection-factory pointing to the new instance of Artemis.  You shouldn't need to create any new modules or anything like that.

          • 2. Re: wildfly-10.1.0.Final multiple artemis servers
            George tsobis Newbie

            Firstly thanks for the fast response.

             

            The system will use the already embedded artemis for internal communication (produce and consume) and the second standalone artemis server for communication from external applications. The external applications are mainly producing but in some rare cases they will also consume from the standalone artemis.

             

            So basically we will have mdbs that consume from the internal artemis and other mdbs that consume from the standalone artemis and all these mdbs will be on the same war. Moreover, in some rare cases we will produce messages from the war to the standalone artemis and remote apps will consume the messages.

             

            Since the standalone version of artemis is different from the internal one, should not I include the artemis-ra-1.5.3 (and all the extra required libs) as a module of wildfly?

             

            Finally, can you give me an example of a pooled-connection-factory for a standalone artemis, or at least point me to reading material because I tried to understand the https://docs.jboss.org/author/display/WFLY10/Messaging+configuration but I am kind of lost.

             

            Thanks again

            Tsobis George

            • 3. Re: wildfly-10.1.0.Final multiple artemis servers
              Justin Bertram Master

              The system will use the already embedded artemis for internal communication (produce and consume) and the second standalone artemis server for communication from external applications. The external applications are mainly producing but in some rare cases they will also consume from the standalone artemis.

              Why not just use the Artemis instance within Wildfly for all your needs?  I'm not clear on why you need to deploy an additional instance.

               

              If you are compelled to set up an Artemis instance external to Wildfly why not configure all clients to use that rather than having 2 brokers running simultaneously.  I can't imagine you're too concerned with performance here since as it currently stands you'll be running both brokers on the same hardware.

               

              Since the standalone version of artemis is different from the internal one, should not I include the artemis-ra-1.5.3 (and all the extra required libs) as a module of wildfly?

              No.  They should be compatible.

               

              Finally, can you give me an example of a pooled-connection-factory for a standalone artemis, or at least point me to reading material because I tried to understand the https://docs.jboss.org/author/display/WFLY10/Messaging+configuration but I am kind of lost.

              The standalone-full.xml already contains a <pooled-connection-factory> which should serve as an example for you.  Just create a new one with appropriate values for "name," "entries," and "connectors."  To be clear, you'll have to create a new connector (e.g. a <remote-connector>) and socket-binding as well.

              • 4. Re: wildfly-10.1.0.Final multiple artemis servers
                Justin Bertram Master

                Also, I believe you can use the @ResourceAdapter annotation on your MDB with the "name" of the relevant <pooled-connection-factory> and the MDB will then use that to connect to the appropriate broker.

                • 5. Re: wildfly-10.1.0.Final multiple artemis servers
                  George tsobis Newbie

                  Unfortunately, the artemis that comes with wildfly does not have the openwire protocol and as you said on another forum post it is not fully functioned on the version that it is embedded.

                   

                  Basically we have to use multiple protocols and since the embedded one is an older version we must use an external one.

                   

                  The need for both instances comes from an old part of the app. The plan is to move all the messaging to the standalone broker (as you are saying), however, to implement the appropriate code changes will take lots of time. Therefore, we will do this gradually and finally depend only on the external one.

                   

                  Thanks to your answers I found this and took a crack at it

                   

                  https://docs.jboss.org/author/display/WFLY10/Connect+a+pooled-connection-factory+to+a+Remote+Artemis+Server?_sscc=t

                   

                   

                   <remote-connector name="remote-artemis" socket-binding="remote-artemis"/>
                  <pooled-connection-factory name="remote-artemis" entries="java:/jms/remoteCF" connectors="remote-artemis" transaction="xa"/>
                  

                   

                   

                  <subsystem xmlns="urn:jboss:domain:naming:2.0">
                              <bindings>
                                  <external-context name="java:global/remoteContext" module="org.apache.activemq.artemis" class="javax.naming.InitialContext">
                                      <environment>
                                          <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
                                          <property name="java.naming.provider.url" value="tcp://localhost:61616"/>
                                          <property name="queue.TsobisQueue" value="TsobisQueue"/>
                                      </environment>
                   </external-context>
                                  <lookup name="java:/TsobisQueue" lookup="java:global/remoteContext/TsobisQueue"/>
                              </bindings>
                              <remote-naming/>
                          </subsystem>
                  

                   

                  <outbound-socket-binding name="remote-artemis">
                              <remote-destination host="localhost" port="61616"/>
                          </outbound-socket-binding>
                  

                   

                   

                  To send message

                   

                  @Resource(lookup = "java:global/remoteContext/TsobisQueue") private Queue remoteQueue;
                      @Inject @JMSConnectionFactory("java:/jms/remoteCF") private JMSContext remoteContext;
                  

                   

                   

                  However, i could not make the mdb to work

                   

                  @MessageDriven(name = "SecondMDB", activationConfig = {
                          @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
                          @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:global/remoteContext/TsobisQueue"),
                          @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1"),
                          @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")
                  })
                  @ResourceAdapter("remote-artemis")
                  public class Second  implements MessageListener
                  {
                          @Inject Logger logger;
                  
                          public void onMessage(Message msg)
                          {
                                  MapMessage message=(MapMessage)msg;
                                  try
                                  {
                                       logger.info("Remote ===================================");
                                 }
                                  catch (JMSException e){logger.info(e);}
                          }
                  }
                  

                   

                   

                  I managed to send the message to both artemis instances, however, the mdb for the remote one does not work. Any ideas?

                  There are not errors on the log files.

                  • 6. Re: wildfly-10.1.0.Final multiple artemis servers
                    Justin Bertram Master

                    I'm not sure why it wouldn't be working.  Your configuration looks correct except for this in your <external-context>:

                     

                    <property name="java.naming.provider.url" value="tcp://localhost:61616"/>

                     

                    It shouldn't be breaking anything, but it's not necessary.

                     

                    You can always try just configuring the MDB directly with the "connectorClassName" (e.g. "org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory") and "connectionParameters" (e.g. "host=localhost;port=61616") activation configuration properties.

                    • 7. Re: wildfly-10.1.0.Final multiple artemis servers
                      George tsobis Newbie

                      Can the problem exist from a wrong library from which I include the Resource Adapter annotation?

                      Should I use the following or is there another package that I did not find?

                       

                      <dependency>
                       <groupId>jboss</groupId>
                       <artifactId>jboss-annotations-ejb3</artifactId>
                       <version>4.2.3.GA</version>
                       </dependency>
                      

                       

                       

                      import org.jboss.annotation.ejb.ResourceAdapter;
                      @ResourceAdapter("remote-artemis")
                      
                      • 8. Re: wildfly-10.1.0.Final multiple artemis servers
                        George tsobis Newbie

                        After numerous minor changes and failures I tested the environment with your suggestion and works.

                        Can I come to a conclusion on what is the problem now?

                         

                        @ActivationConfigProperty(propertyName = "connectorClassName", propertyValue = "org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory"),
                        @ActivationConfigProperty(propertyName = "connectionParameters", propertyValue = "host=localhost;port=61616")
                        
                        • 9. Re: wildfly-10.1.0.Final multiple artemis servers
                          Justin Bertram Master

                          Yes, using the wrong annotation would be a problem, and it appears that you are, in fact, using the wrong one.  You appear to be using a very old version rather than the one shipped with Wildfly.  You should be using org.jboss.ejb3.annotation.ResourceAdapter from here.  Try using this one and see how it goes.

                          • 10. Re: wildfly-10.1.0.Final multiple artemis servers
                            George tsobis Newbie

                            Everything works ok now.

                            Thanks, your instructions where super helpful.

                            Regards

                            Tsobis George