Sun GlassFish Enterprise Server 2.1 High Availability Administration Guide

Using MQ Clusters with Enterprise Server

MQ Enterprise Edition supports multiple interconnected broker instances known as a broker cluster. With broker clusters, client connections are distributed across all the brokers in the cluster. Clustering provides horizontal scalability and improves availability.

This section describes how to configure Enterprise Server to use highly available Sun Java System Message Queue clusters. It explains how to start and configure Message Queue clusters.

For more information about the topology of Enterprise Server and MQ deployment, see the Planning Message Queue Broker Deployment chapter in the Sun GlassFish Enterprise Server 2.1 Deployment Planning Guide. .

Highly Available MQ Clusters

Sun Java System Message Queue 4.1 provides a highly available messaging service through a new "Highly Available" cluster type. In an MQ cluster of this type, all the broker instances would share a peer– to–peer relationship and all its broker instances would share a common persistent data store thus offering 'Data Availability.' Instances would automatically be able to detect if an instance fails and perform a takeover of the failed broker's persistent messages, dynamically through a takeover election. Application components that are deployed in the application server could thus leverage these availability features.

With this cluster type, there would not be any loss of transacted persistent messages to a queue or a durable topic subscription. Non-persistent messages or persistent messages to non-durable subscribers are likely to be lost when the broker that the client runtime is connected to is unavailable.

Configuring a Highly Available Broker Cluster in the Local Mode

  1. Start HADB.

  2. Create a domain and start it. To create a domain and start it, use the asadmin commands, create-domain and start-domain respectively. For more information about these commands, see create-domain(1) and start-domain(1).

  3. Create a node agent and start it. To create a node agent and start it, use the asadmin commands, create-node-agent and start-node-agent respectively. For more information about these commands, see create-node-agent(1) and start-node-agent(1).

  4. Create a cluster. You can create a cluster either using the asadmincommand, create-cluster or using the Admin Console. For more information on the create-cluster command, see create-cluster(1). For information on how to create a cluster using the Admin Console, see the Admin Console Online Help.

  5. Create instances in the cluster. While creating an instance, specify the JMS Provider port number being used by the remote broker. If you do not specify one, it will take the default JMS Provider port number. You can create instances using the Admin Console or the asadmin command, create-instance. For information on how to create instances using the Admin Console, see the Admin Console Online Help. For information on the create-instance command, see create-instance(1).

  6. Start the cluster. You can do this from the Admin Console or using the asadmin command start-cluster. For information on how to start a cluster using the Admin Console, refer to the Admin Console Online Help. For information on the start-cluster command, see start-cluster(1).

  7. Configure the HA cluster using the asadmin command, configure-ha-cluster. For more information about the command, see configure-ha-cluster(1).

Configuring a Highly Available Broker Cluster in the Remote Mode

  1. Start HADB.

  2. Create database tables.

  3. Copy the HA driver if you are creating a highly available broker cluster.

    cp $AS_HOME/hadb/4.4.3-6/lib/hadbjdbc4.jar $S1AS_HOME/imq/lib/ext
  4. Create a domain and start it. To do this, use the commands asadmin create-domain and start-domain. For more information about these commands, see create-domain(1) and start-domain(1).

  5. Create a node agent and start it. To do this, use the asadmin commands create-domain and start-node-agent. For more information about these commands, see create-node-agent(1) and start-node-agent(1).

  6. Create a cluster. You can create a cluster either using the asadmin command create-cluster or using the Admin Console. For more information, see create-cluster(1). For information on how to create a cluster using the Admin Console, see the Admin Console Online Help.

  7. Create instances in the cluster. While creating an instance, specify the JMS Provider port number being used by the remote broker. If you do not specify one, it will take the default JMS Provider port number.

  8. Delete the default JMS Host and create JMS hosts to which the instances can connect. Be sure to add each broker as a separate JMS host. For more information on JMS Hosts, see JMS Hosts List.

  9. Set the JMS type as Remote. You can do this using the asadmin command set or from the JMS Service page in the Admin Console.

  10. Set JMS Availability to true if you are configuring a highly available broker. You can do this using the asadmin command set or from the JMS Availability page in the Admin Console.

  11. Start the broker instances.

  12. Start the cluster. For more information, see start-cluster(1).

Auto-clustering for non-HA Clusters

Till now, the administrator had to set up 'non-Highly Available' MQ clusters (MQ clusters with a master broker) separately as explained in the procedure following this section. In this release, in addition to the manual process (of type REMOTE) of setting up an MQ cluster, Enterprise Server provides 'auto-clustering,' which means that a co-located non-HA cluster (of type LOCAL) will be created automatically when a user creates an Application Server cluster. This will be the default mode of creating MQ clusters. For example, when the administrator creates an Application Server cluster with three Application Server instances, each Application Server instance will be configured to work with a co-located broker, and as a result the three MQ broker instances will be made to form an MQ cluster transparently. The first Application Server instance's MQ broker will be set to be the master broker. Auto-clustering, however, has a disadvantage too. If the administrator adds an instance to the cluster, the MQ broker instance created automatically will not be able to take part in the cluster. This behavior also applies if an instance is removed from the cluster.

ProcedureTo Enable MQ Clusters with Enterprise Server Clusters

Before You Begin

Perform the following steps if the cluster is of type REMOTE. If the cluster is of type LOCAL, steps 1 to 4 are not applicable .

  1. Create a cluster, if one does not already exist.

    For information on creating clusters, see To Create a Cluster.

  2. Create an MQ broker cluster.

    First, delete the default JMS host that refers to the broker started by the Domain Administration Server, and then create three external brokers (JMS hosts) that will be in the MQ broker cluster.

    Create a JMS host with either the Admin Console or the asadmin command-line utility.

    To use asadmin, the commands are for example:


    asadmin delete-jms-host --target cluster1 default_JMS_host
    asadmin create-jms-host --target cluster1
         --mqhost myhost1 --mqport 6769
         --mquser admin --mqpassword admin broker1
    asadmin create-jms-host --target cluster1
         --mqhost myhost2 --mqport 6770
         --mquser admin --mqpassword admin broker2
    asadmin create-jms-host --target cluster1
         --mqhost myhost3 --mqport 6771
         --mquser admin --mqpassword admin broker3

    To create the hosts with Admin Console:

    1. Navigate to the JMS Hosts node (Configurations > config-name > Java Message Service > JMS Hosts)

    2. Delete the default broker (default_JMS_host).

      Select the checkbox next to it, and then click Delete.

    3. Click New to create each JMS host and enter its property values.

      Fill in the values for host name, DNS name or IP address, port number, administrative user name and password.

  3. Start the master MQ broker and the other MQ brokers.

    In addition to the three external brokers started on JMS host machines, start one master broker on any machine. This master broker need not be part of a broker cluster. For example:


    /usr/bin/imqbrokerd -tty -name brokerm -port 6772
     -cluster myhost1:6769,myhost2:6770,myhost2:6772,myhost3:6771
     -D"imq.cluster.masterbroker=myhost2:6772"
  4. Start the instances in the cluster.

  5. Create JMS resources on the cluster:

    1. Create JMS physical destinations.

      For example, using asadmin:


      asadmin create-jmsdest --desttype queue --target cluster1 MyQueue
      asadmin create-jmsdest --desttype queue --target cluster1 MyQueue1

      To use Admin Console:

      1. Navigate to the JMS Hosts page (Configurations > config-name > Java Message Service > Physical Destinations).

      2. Click New to create each JMS physical destination.

      3. For each destination, enter its name and type (queue).

    2. Create JMS connection factories.

      For example, using asadmin:


      asadmin create-jms-resource --target cluster1
      --restype javax.jms.QueueConnectionFactory jms/MyQcf
      asadmin create-jms-resource --target cluster1
      --restype javax.jms.QueueConnectionFactory jms/MyQcf1

      To use Admin Console:

      1. Navigate to the JMS Connection Factories page (Resources > JMS Resources > Connection Factories).

      2. To create each connection factory, click New.

        The Create JMS Connection Factory page opens.

      3. For each connection factory, enter JNDI Name (for example jms/MyQcf) and Type, javax.jms.QueueConnectionFactory

      4. Select the cluster from the list of available targets at the bottom of the page and click Add.

      5. Click OK to create the connection factory.

    3. Create JMS destination resources.

      For example, using asadmin:


      asadmin create-jms-resource --target cluster1
           --restype javax.jms.Queue
           --property imqDestinationName=MyQueue jms/MyQueue
      asadmin create-jms-resource --target cluster1
           --restype javax.jms.Queue
           --property imqDestinationName=MyQueue1 jms/MyQueue1

      To use Admin Console:

      1. Navigate to the JMS Destination Resources page (Resources > JMS Resources > Connection Factories).

      2. To create each destination resource, click New.

        The Create JMS Destination Resource page opens.

      3. For each destination resource, enter JNDI Name (for example jms/MyQueue) and Type javax.jms.Queue.

      4. Select the cluster from the list of available targets at the bottom of the page and click Add.

      5. Click OK to create the destination resource.

  6. Deploy the applications with the – retrieve option for application clients. For example:


    asadmin deploy --target cluster1 
    --retrieve /opt/work/MQapp/mdb-simple3.ear
  7. Access the application and test it to ensure it is behaving as expected.

  8. If you want to return the Enterprise Server to its default JMS configuration, delete the JMS hosts you created and recreate the default. For example:


    asadmin delete-jms-host --target cluster1 broker1
    asadmin delete-jms-host --target cluster1 broker2
    asadmin delete-jms-host --target cluster1 broker3
    asadmin create-jms-host --target cluster1
     --mqhost myhost1 --mqport 7676
     --mquser admin --mqpassword admin
     default_JMS_host

    You can also perform the equivalent operation with Admin Console.

Troubleshooting

If you encounter problems, consider the following: