5 Replies Latest reply on May 20, 2015 11:04 PM by jbertram

    Sending messages to Wildfly with configured bridge

    filippo.de.rosa

      Hi everybody,

       

      I'll try to explain what's my aim first and then share the actual implementation then eventually the problem I have.

       

      Current situation and goal: I have an embedded HornetQ instance running in Tomcat and a separate Wildfly 8.2.0 instance. What I need to do is have a bridge between the two (it's a client requirement) and when the messages are sent to Wildfly then the bridge will forward the message to the embedded HornetQ. This has been done (please see following configuration) and the final step would be to setup load tests for the bridge with JMeter.

       

      Current configuration:

       

      • Embedded HornetQ listening on 127.0.0.1:5445
      • Wildfly configuration as follow:
        <subsystem xmlns="urn:jboss:domain:messaging:2.0">
                    <hornetq-server>
                        <journal-file-size>102400</journal-file-size>
                        <connectors>
                            <netty-connector name="netty-connector" socket-binding="my-jms-broker"/>
                            <http-connector name="http-connector" socket-binding="http">
                                <param key="http-upgrade-endpoint" value="http-acceptor"/>
                            </http-connector>
                            <http-connector name="http-connector-throughput" socket-binding="http">
                                <param key="http-upgrade-endpoint" value="http-acceptor-throughput"/>
                                <param key="batch-delay" value="50"/>
                            </http-connector>
                            <in-vm-connector name="in-vm" server-id="0"/>
                            <connector name="remote-hornetq-nonmanaged">
                                <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
                                <param key="host" value="127.0.0.1"/>
                                <param key="port" value="5445"/>
                            </connector>
                            <netty-connector name="remote-hornetq-managed" socket-binding="remote-hornetq-binding"/>
                        </connectors>
                        <acceptors>
                            <http-acceptor name="http-acceptor" http-listener="default"/>
                            <http-acceptor name="http-acceptor-throughput" http-listener="default">
                                <param key="batch-delay" value="50"/>
                                <param key="direct-deliver" value="false"/>
                            </http-acceptor>
                            <in-vm-acceptor name="in-vm" server-id="0"/>
                            <acceptor name="remote-hornetq-nonmanaged">
                                <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
                                <!-- <param key="host" value="127.0.0.1"/> -->
                                <param key="port" value="6000"/>
                            </acceptor>
                        </acceptors>
                        <security-enabled>false</security-enabled>
                        <security-settings>
                            <security-setting match="#">
                                <permission type="send" roles="guest"/>
                                <permission type="consume" roles="guest"/>
                                <permission type="createNonDurableQueue" roles="guest"/>
                                <permission type="deleteNonDurableQueue" roles="guest"/>
                                <permission type="createDurableQueue" roles="guest"/>
                                <permission type="deleteDurableQueue" roles="guest"/>
                            </security-setting>
                        </security-settings>
                        <address-settings>
                            <!--default for catch all-->
                            <address-setting match="#">
                                <dead-letter-address>jms.queue.DLQ</dead-letter-address>
                                <expiry-address>jms.queue.ExpiryQueue</expiry-address>
                                <max-size-bytes>10485760</max-size-bytes>
                                <page-size-bytes>2097152</page-size-bytes>
                                <message-counter-history-day-limit>10</message-counter-history-day-limit>
                            </address-setting>
                        </address-settings>
                        <jms-connection-factories>
                            <connection-factory name="InVmConnectionFactory">
                                <connectors>
                                    <connector-ref connector-name="in-vm"/>
                                </connectors>
                                <entries>
                                    <entry name="java:/ConnectionFactory"/>
                                </entries>
                            </connection-factory>
                            <connection-factory name="RemoteConnectionFactory">
                                <connectors>
                                    <!-- <connector-ref connector-name="http-connector"/> -->
                                    <connector-ref connector-name="netty-connector"/>
                                    <connector-ref connector-name="remote-hornetq-nonmanaged"/>
                                </connectors>
                                <entries>
                                    <entry name="RemoteConnectionFactory"/>
                                    <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                                </entries>
                            </connection-factory>
                            <pooled-connection-factory name="hornetq-ra">
                                <transaction mode="xa"/>
                                <connectors>
                                    <connector-ref connector-name="in-vm"/>
                                </connectors>
                                <entries>
                                    <entry name="java:/JmsXA"/>
                                    <!-- Global JNDI entry used to provide a default JMS Connection factory to EE application -->
                                    <entry name="java:jboss/DefaultJMSConnectionFactory"/>
                                </entries>
                            </pooled-connection-factory>
                            <pooled-connection-factory name="remote-hornetq-ra">
                                <connectors>
                                    <connector-ref connector-name="remote-hornetq-nonmanaged"/>
                                </connectors>
                                <entries>
                                    <entry name="java:/remoteJmsXA"/>
                                </entries>
                            </pooled-connection-factory>
                        </jms-connection-factories>
                        <jms-destinations>
                            <jms-queue name="ExpiryQueue">
                                <entry name="java:/jms/queue/ExpiryQueue"/>
                            </jms-queue>
                            <jms-queue name="DLQ">
                                <entry name="java:/jms/queue/DLQ"/>
                            </jms-queue>
                            <jms-queue name="IncomingQueue">
                                <entry name="java:/jms/queue/IncomingQueue"/>
                                <entry name="java:jboss/exported/jms/queue/IncomingQueue"/>
                            </jms-queue>
                            <jms-queue name="OutgoingQueue">
                                <entry name="java:/jms/queue/OutgoingQueue"/>
                                <entry name="java:jboss/exported/jms/queue/OutgoingQueue"/>
                            </jms-queue>
                        </jms-destinations>
                    </hornetq-server>
                    <jms-bridge name="simple-jms-bridge">
                        <source>
                             <connection-factory name="ConnectionFactory"/>
                             <destination name="/jms/queue/OutgoingQueue"/>
                        </source>
                        <target>
                            <connection-factory name="RemoteConnectionFactory"/>
                            <destination name="/jms/queue/IncomingQueue"/>
                        </target>
                        <quality-of-service>AT_MOST_ONCE</quality-of-service>
                        <failure-retry-interval>1000</failure-retry-interval>
                        <max-retries>-1</max-retries>
                        <max-batch-size>10</max-batch-size>
                        <max-batch-time>100</max-batch-time>
                    </jms-bridge>
                </subsystem>
                <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:50}">
                    <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
                    <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
                    <socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
                    <socket-binding name="http" port="${jboss.http.port:8080}"/>
                    <socket-binding name="https" port="${jboss.https.port:8443}"/>
                    <socket-binding name="jacorb" interface="unsecure" port="3528"/>
                    <socket-binding name="jacorb-ssl" interface="unsecure" port="3529"/>
                    <socket-binding name="messaging-group" port="0" multicast-address="${jboss.messaging.group.address:231.7.7.7}" multicast-port="${jboss.messaging.group.port:9876}"/>
                    <socket-binding name="txn-recovery-environment" port="4712"/>
                    <socket-binding name="txn-status-manager" port="4713"/>
                    <outbound-socket-binding name="mail-smtp">
                        <remote-destination host="localhost" port="25"/>
                    </outbound-socket-binding>
                    <outbound-socket-binding name="remote-hornetq-binding">
                        <remote-destination host="127.0.0.1" port="5445"/>
                    </outbound-socket-binding>
                    <socket-binding name="my-jms-broker" port="${my.broker.port:5445}"/>
                </socket-binding-group>
        

       

      • JMeter is connecting trough the RemoteConnectionFactory using the http-remoting://127.0.0.1:8130 (because I have an offset of 50)

       

      Problem: Sometime the bridge works and sometimes not. I would like to load thousands of messages using JMeter to the Wildfly instance (on the OutgoingQueue) and then when I start the embedded HornetQ instance then the bridge should start sending messages. For some reason though the messages from JMeter are going to the IncomingQueue (instead of OutgoingQueue) in the Wildfly instance and hence never picked up by the embedded HornetQ instance, they are just sitting in the IncomingQueue.

        • 1. Re: Sending messages to Wildfly with configured bridge
          jbertram

          Couple of things:

          1. Performance will be better if you use a "core" bridge rather than a JMS bridge.
          2. Your configuration is a big mess:
            1. The JMS bridge "target" is referencing a local connection factory and that connection factory has 2 connectors for some reason I can't understand.
            2. You have an acceptor listening on port 6000 for some reason I don't understand.
            3. You've got a couple of unnecessary socket bindings.

           

          I recommend you get start your Wildfly configuration from scratch, add OutgoingQueue, and then just add a core bridge to move messages from OutgoingQueue to the remote IncomingQueue.  You can read about core bridges in the HornetQ User Guide.

          • 2. Re: Sending messages to Wildfly with configured bridge
            filippo.de.rosa

            Hi Justin,

             

            Thanks very much for your reply.


            I know my configuration it's bit messy, I was trying some possible solutions. I've cleaned up the elements you mentioned. In the RemoteConnectionFactory I left only the remote-hornetq-nonmanaged connector.

             

            I didn't know about the "core" bridges, so many thanks for the hint. Only one thing is not clear also from the documentation and is where I specify the remote IncomingQueue: I understand that the queue-name specifies where to consume the messages from, but I can't see where to specify the remote IncomingQueue.

             

            Thanks,

            Filippo

            • 3. Re: Sending messages to Wildfly with configured bridge
              jbertram

              I didn't know about the "core" bridges, so many thanks for the hint. Only one thing is not clear also from the documentation and is where I specify the remote IncomingQueue: I understand that the queue-name specifies where to consume the messages from, but I can't see where to specify the remote IncomingQueue.

              The remote queue is specified on the remote server.

              • 4. Re: Sending messages to Wildfly with configured bridge
                filippo.de.rosa

                Thank for your reply Justin.

                 

                Does this mean that I need to have the same configuration on the remote server? Or how do I specify on the remote server where to receive the message coming from the bridge?

                 

                Many thanks,

                Filippo

                • 5. Re: Sending messages to Wildfly with configured bridge
                  jbertram

                  No, you don't need the same configuration on the remote server as you have on the local server.  You just need to define the queue/address which will receive the message.