2 Replies Latest reply on Feb 26, 2015 3:00 AM by Stefan Schubert

    WildFly MDB consumer with remote queue

    Vojislav Misic Newbie

      I have two servers(both wildfly8). On server 1 i have a queue. On server 2 i have a mdb consumer. My question is how to configure the consumer to consume messages from the queue on server 1.

      Messaging subsystem attached.

      The bean should look something like this:

       

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

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

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

          @ActivationConfigProperty(propertyName = "java.naming.provider.url", propertyValue = "http-remoting://server1:8080"),

          @ActivationConfigProperty(propertyName = "reconnectAttempts", propertyValue = "-1"),  

          @ActivationConfigProperty(propertyName = "setupAttempts", propertyValue = "-1")})

      public class MessageConsumerMDB implements MessageListener {

         

          public MessageConsumerMDB() {

          }

         

          @Override

          public void onMessage(Message message) {

          TextMessage tm = (TextMessage)message;

              try {

                  System.out.println("Message is : " + tm.getText());

              } catch (JMSException e) {

                  e.printStackTrace();

              }

          }

      }

       

      What am I doing wrong?

        • 1. Re: WildFly MDB consumer with remote queue
          Aditya Kumar Newbie

          Were you able to resolve this problem? Any update?

          • 2. Re: WildFly MDB consumer with remote queue
            Stefan Schubert Newbie

            I'm working on the same problem atm, however i can't get it to work, but maybe my experiences help you.

            As far as i understood, you need a user on the server, that holds the Queue, who is used in the connection.

             

            So on the server with the queue, you use add-user.bat to create a Application User, lets say with name <<NAME>>.
            When the CLI asks you, if the user should be used in a remote connection (the last step of the user creation), say yes and save the Base64 encodes secret identity (lets call it <<IDENT>>) it gives you.

             

            On the server holding the MBD, you need a new security realm, so put the following into the server2.xml

            <security-realms>

            ..

              <security-realm name="queue-security-realm">

                <server-identities>

                  <secret value="<<IDENT>>"/>

                </server-identities>

              </security-realm>

            ...

            </security-realms>

             

            You now need an outbound-socket-binding to the host:port, server1 is running on, like localhost:8080. Put this also into the server2.xml

            <socket-binding-group ....>

            ...

              <outbound-socket-binding name="remote-queue">

                <remote-destination host="localhost" port="8080"/>

              </outbound-socket-binding>

            ...

            </socket-binding-group>

             

            At last, you can define the connection from server2 to server1, by putting this into the server2.xml

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

            ...

              <outbound-connections>

                <remote-outbound-connection name="remote-queue-connection" outbound-socket-binding-ref="remote-queue" username="<<NAME>>" security-realm="queue-security-realm" protocol="http-remoting">

                  <properties>

                    <property name="SASL_POLICY_NOANONYMOUS" value="false"/>

                    <property name="SSL_ENABLED" value="false"/>

                  </properties>

                </remote-outbound-connection>

              </outbound-connections>

            ... 

            </subsystem>

             

            Note, how the remote outbound connection depends on the outbound socket binding and the security realm.

            Now as far as i understand, this is used, to establish a connection from server2 to server1 to use the objects, that are mapped in the JNDI of server1.

            Maybe this works for you.

            If it does, i would be more than happy, if you could push your project into GitHub and send me the link, since im working on the same issue.

             

            Best wishes

            Urr4

            1 of 1 people found this helpful