5 Replies Latest reply on Jun 13, 2016 10:16 AM by jbertram

    Restrict consumer connection per queue

    ronyjhn

      Hi All,

        Is it possible to restrict consumer connection per queue? Any configuration changes?

        • 1. Re: Restrict consumer connection per queue
          jbertram

          You can prevent a user from consuming from a queue by enforcing security authorization, but there is no way to limit the number of consumers on a queue.

          • 2. Re: Restrict consumer connection per queue
            ronyjhn

            Thank you so mush for your reply.

            We are facing a problem of multiple connection exists at HornetQ server side for single queue when we stop  and start our consumer/listener program.

            Normally it happen when we close consumer program without proper resource release. I don't want unused connection at server that can cause currently connected listener to lose messages from queue.

                  Is it possible to check using some HornetQ API to detect the number of consumers, when I connect next time?

            • 3. Re: Restrict consumer connection per queue
              jbertram

              Typically if you close an application without closing your resources then HornetQ will detect the dead connection and remove it automatically.  What connection factory are your clients using and how is that connection factory configured?

               

              And yes, there is a way to determine the number of consumers on a given queue via the management API.  The relevant property is called "consumerCount" and it's available on the QueueControl.  Check out the HornetQ management documentation as well as the "management" example shipped with HornetQ for a working demonstration of how to retrieve a management property for a queue.

              • 4. Re: Restrict consumer connection per queue
                ronyjhn

                I configured JNDI based connection factory in hornetq-configuration.xml using NettyConnectionFactory. I agreed with your point on dead connection handling of HornetQ.

                Sometimes in our test environment, we faced with connection break issues. So I went with connection-ttl=-1 and client-failure-check-period to a maximum value approach.

                    Definitely I will check the documentation and will try out the API which you mentioned for consumerCount. Thanks again for your prompt responses.

                • 5. Re: Restrict consumer connection per queue
                  jbertram

                  As you've observed, the problem with setting connection-ttl=-1 and client-failure-check-period to a maximum value is that dead connections will just leak instead of being cleaned up.