Uploaded image for project: 'AMQ Broker'
  1. AMQ Broker
  2. ENTMQBR-3232

Good practices for equally distributing queue consumers in a cluster

XMLWordPrintable

    • Icon: Story Story
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • None
    • None
    • Documentation (Ref Guide, User Guide, etc.)

      Hi,

      Below are a few good practices that we encountered for equally distributing queue consumers over an AMQ Cluster.

      • It is recommended that for a Java application that is deployed in EAP, to make use of Resource Adapters (RA) in EAP to connect to AMQ Broker.
      • The Java application must not make a direct connection with the AMQ broker. Instead, use the JNDI connection from the EAP. EAP can handle the connections more efficiently and there is no overhead on application to take care of the connections.
      • The connection pool in EAP takes care of evenly distributing the AMQ consumers. If any AMQ instance goes down, the EAP takes care of rebalancing the consumers. This helps to maintain a constant number of consumers for any queue.
      • It is recommended to implement queue consumers using MDB. Since MDB uses a push-based mechanism instead of a polling mechanism. The polling mechanism creates connection every time it connects to AMQ Broker which creates an overhead for the AMQ broker.

      JAVA Application POC
      The sample application discussed here uses a JEE implementation and it is deployed in EAP. The following important resources are used in the application:

      Resource Adapter:
      The application makes use of the Resource Adapter present in EAP to make connections to the AMQ broker. EAP’s resource adapter creates a connection pool with the AMQ broker that helps in improving the performance of the application.
      The responsibility of maintaining a connection with the AMQ broker is handed over to EAP’s RA.

      Message Driven Beans(MDB):
      The application makes use of MDBs to consume messages from the AMQ broker. The MDB uses a push-based mechanism for consuming messages so the connection with the AMQ broker is never destroyed until the consumer is up and running.

      JNDI Connection:
      It is recommended to use the JNDI connection configured in AMQ while making a connection with the AMQ broker.

      Making a connection without JNDI can lead to unequal distribution of the connections to the AMQ brokers.

      The sample Java application for producing and consuming messages from the AMQ broker is shared at the GitHub URL.

      link AMQ-JAVA-Sample Git

            jcliffor@redhat.com John Clifford
            rhn-support-shchavan Shrikant Chavan (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: