4 Replies Latest reply on Mar 25, 2011 9:59 AM by Paul Slattery

    Predefined local port for bridge connection

    Paul Slattery Newbie

      I have a question regarding the ability to set options on the NettyConnectionFactory to specify the local port for a bridge connection between two Hornet instances ?


      Our setup is the following:

      • A local HornetQ broker that is running on machine x
      • Many Tomcat instances running also on x listening to predefined topics on the local broker.
      • A master HornetQ instance running on y
      • A bridge connection between local x and master y


      Our HornetQ instances will startup first. These will create a socket connection on a remote port on master y and a randomly selected local port on x.At the moment this local port on x is determined natively and is not controllable.

      We have a large range of local frontends that will start next in sequence. The problem is that the frontends will try to create server sockets within port ranges when they start.If one of these is bound to the local port used in the bridge connection to y, then the frontend server socket creation will fail.


      The question is whether we can easily (using the microcontainer etc.) set the NettyConnector option 'localport' on x startup ? We can then declare a local port that we know will not be used by our frontends.


      Can this be done ?

        • 1. Predefined local port for bridge connection
          jeroen.v Newbie

          What do you mean exactly by local HornetQ and master HornetQ? Are these a live node and a backup node? Or both live nodes in a cluster?


          If you are talking about 2 live nodes in a cluster, they behave the same: a local port where they are available (like localserver:5445). In case they connect to another cluster member they start a connection to the remote machine (remoteserver:5445) and bind to a local port (like localserver:52000).

          • 2. Predefined local port for bridge connection
            Paul Slattery Newbie

            They are neither.

            One is a local hornetQ broker with tasked with updating the local frontends. The other is a 'master' broker instance that is responsible for routing logic between local brokers (using a series of diverts and local forward queues)

            They are connected via a bridge,

            It is precisely the binding to the local port that I would like to control. Looking through the netty source code, there seems to be 'options' for this defined at that level , but not exposed by hornetq

            • 3. Predefined local port for bridge connection
              Andy Taylor Master

              currently its not possible to set the local port altho we could easily add it. I'm not sure how valid it is tho as this would be configurable on the server side and would be used by all clients, firstly only 1 client from a machine would be able to connect at any one time and an assumption would be made that any other clients on other machines would have this port free.


              If you want it raise a jira and we'll take a look sometime, even better attach a patch to the jira for the fix.

              • 4. Predefined local port for bridge connection
                Paul Slattery Newbie

                Ok, agreed , there would not be much point for client side, but we may have a use-case here for the special case of broker to broker bridges where we could directly specify.

                If this case arises I will open a Jira and add the suggested patch code.