3 Replies Latest reply on Dec 1, 2016 3:19 AM by Ildar Gilfanov

    WildFly 10.0.0 Final. How to configure pooled-connection-factory for multiple fixed addresses?

    Ildar Gilfanov Newbie

      How to configure pooled-connection-factory for multiple fixed addresses?

       

      The messaging-activemq subsystem allows to configure a pooled-connection-factory resource to let a local client deployed in WildFly 10.0.0 Final connect to a remote WildFly 10.0.0 Final server.

       

      When a pooled-connection-factory is configured to connect to a remote WildFly 10.0.0 Final, it is possible to configure Message-Driven Beans (MDB) to have them consume messages from this remote server.

       

      If the MDB needs to produce messages to the remote server, it must inject the pooled-connection-factory by looking it up in JNDI using one of its entries.

       

      standalone-full-ha.xml:

       

      <subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
          <server name="default">
               ...
               <remote-connector name="remote-jms-1" socket-binding="remote-jms-1"/>
               ...
               <pooled-connection-factory name="remote-jms" password="jmsguest" user="jmsguest" entries="java:/jms/remoteCF" connectors="remote-jms-1"/>
          </server>
      </subsystem>
      
      
      
      <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
              ....
              <outbound-socket-binding name="remote-jms-1">
                  <remote-destination host="172.16.2.1" port="8080"/>
              </outbound-socket-binding>
              <outbound-socket-binding name="remote-jms-2">
                  <remote-destination host="172.16.2.2" port="8080"/>
              </outbound-socket-binding>
      </socket-binding-group>
      
      

       

      If the decision involves bridges, it is possible to configure multiple bridges for single pooled-connection-factory?

       

      If the decision involves JNDI-naming, it is possible to configure multiple JNDI for single pooled-connection-factory?

        • 1. Re: WildFly 10.0.0 Final. How to configure pooled-connection-factory for multiple fixed addresses?
          Justin Bertram Master

          When a pooled-connection-factory is configured to connect to a remote WildFly 10.0.0 Final, it is possible to configure Message-Driven Beans (MDB) to have them consume messages from this remote server.

          Yes.

           

          If the decision involves bridges, it is possible to configure multiple bridges for single pooled-connection-factory?

           

          If the decision involves JNDI-naming, it is possible to configure multiple JNDI for single pooled-connection-factory?

          I'm not really sure what you're asking in either of these questions.  Please elaborate.  Describe your full use-case if possible.

          • 2. Re: WildFly 10.0.0 Final. How to configure pooled-connection-factory for multiple fixed addresses?
            Ildar Gilfanov Newbie

            I found a solution:

             

            <subsystem xmlns="urn:jboss:domain:naming:2.0">

               <bindings>

                   <external-context name="java:/global/RemoteServer" module="org.jboss.as.naming" class="javax.naming.InitialContext" cache="true">

                       <environment>

                           <property name="java.naming.factory.initial" value="org.jboss.naming.remote.client.InitialContextFactory"/>

                           <property name="java.naming.provider.url" value="http-remoting://172.16.1.1:8080,http-remoting://172.16.1.2:8080"/>

                           <property name="java.naming.security.principal" value="jmsguest"/>

                           <property name="java.naming.security.credentials" value="jmsguest"/>

                       </environment>

                   </external-context>

                   <lookup name="java:global/ExportedQueue" lookup="java:/global/RemoteServer/jms/queue/MyQueue"/>

                   <lookup name="java:global/ExportedTopic" lookup="java:/global/RemoteServer/jms/topic/MyTopic"/>

                   <lookup name="java:global/ExportedFactory" lookup="java:/global/RemoteServer/jms/RemoteConnectionFactory"/>

               </bindings>

               <remote-naming/>

            </subsystem>

             

             

            • Sample Producer

             

            public class MessageProducer {

             

            @Inject

            @JMSConnectionFactory("java:global/ExportedFactory")

            @JMSPasswordCredential(userName = "jmsguest", password = "jmsguest")

            private JMSContext context;

             

            @Resource(lookup = "java:global/ExportedQueue")

            private Queue queue;

             

            • Sample Receiver

            @MessageDriven(name = "MessageReceiver", activationConfig = {

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

                    @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "true"),

                    @ActivationConfigProperty(propertyName=  "connectionFactoryLookup", propertyValue = "java:global/ExportedFactory"),

                    @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:global/ExportedTopic"),

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

                    @ActivationConfigProperty(propertyName = "user", propertyValue = "jmsguest"),

                    @ActivationConfigProperty(propertyName = "password", propertyValue = "jmsguest")})

            public class MessageReceiver implements MessageListener {

             

             

             

            How to dispose:

             

            @JMSPasswordCredential(userName = "jmsguest", password = "jmsguest")

             

            and

            @ActivationConfigProperty(propertyName = "user", propertyValue = "jmsguest"),

            @ActivationConfigProperty(propertyName = "password", propertyValue = "jmsguest")

             

            ?

            • 3. Re: WildFly 10.0.0 Final. How to configure pooled-connection-factory for multiple fixed addresses?
              Ildar Gilfanov Newbie

              this solution is unstable (does not always work):

              1-Dec-2016 09:18:54.125 Caused By: javax.naming.NamingException: WFLYNAM0062: Filed to lookup ExportedQueue [Root exception is java.lang.RuntimeException: javax.naming.NamingException: Unable to invoke lookup, status=WAITING]
                at org.jboss.naming.remote.protocol.v1.Protocol$1.execute(Protocol.java:98)
                at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.lookup(RemoteNamingStoreV1.java:95)
                at org.jboss.naming.remote.client.HaRemoteNamingStore$1.operation(HaRemoteNamingStore.java:275)
                at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:132)
                at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:271)
                at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)
                at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)
                at javax.naming.InitialContext.lookup(InitialContext.java:411)
                at javax.naming.InitialContext.lookup(InitialContext.java:411)

               

               

              What could be wrong? And does not help option @JMSSessionMode(JMSContext.DUPS_OK_ACKNOWLEDGE)

              Messages in the case of this exception is not re-sent.

               

              @Stateless
              public class SomeProducerBean {

                

                  private static final Logger logger = LoggerFactory.getLogger(SomeProducerBean.class);

               

                 @Inject
                @JMSConnectionFactory("java:global/ExportedFactory")

                 @JMSSessionMode(JMSContext.DUPS_OK_ACKNOWLEDGE)

                 @JMSPasswordCredential(userName = "${VAULT::messaging::userName::1}", password = "${VAULT::messaging::password::1}")

                 private JMSContext jmsContext;

               

                 @Resource(lookup = "java:global/ExportedQueue")

                 private Destination requestQueue;

              ...

              jmsContext.createProducer().setAsync(new CompletionListener() {

               

                 @Override
                 public void onCompletion(Message message) {

               

                 logger.debug("Acked by server: message [{}], JMSCorrelationID: [{}]", message.toString(), jmsCorrelationID);

                }

               

                 @Override
                 public void onException(Message message, Exception exception) {

                 logger.error("Unable to send: message [{}], JMSCorrelationID: [{}]", message.toString(), jmsCorrelationID);

                }

               

              }).send(requestQueue, message);

               

              ...