IBM Integration Bus, Version 9.0.0.8 Operating Systems: AIX, HP-Itanium, Linux, Solaris, Windows, z/OS

See information about the latest product version

Using a broker with an existing high availability manager

You can use IBM® Integration Bus with an existing high availability manager, for example HACMP™, HA/XD, VCS, or HP-UX Serviceguard.

With the introduction of multi-instance message brokers in WebSphere® Message Broker Version 7.0, configuring IBM Integration Bus with a high availability (HA) manager is much easier. Previously, support pack IC91 was provided to assist in configuring this requirement.

A number of scripts were provided, but most of these are no longer required because IBM Integration Bus has built in many of the functions as a result of the multi-instance work.

This topic summarizes how to complete the following tasks:
  1. Create a broker.
  2. Add a broker instance.
  3. Start a broker.
  4. Stop a broker.
  5. Monitor a broker.
  6. Delete a broker.
  1. To create a broker, mount the shared resource onto your primary node and use the following mqsicreatebroker command with the -e parameter to specify your shared resource location.
     mqsicreatebroker MyBroker -q MQ1 -e /MQHA/MyBroker/
    where:
    • MyBroker is the name of the broker.
    • MQ1 is the name of the queue manager.
    • /MQHA/MyBroker/ is the directory for your shared resource.
  2. To add another broker instance, mount the shared resource onto your secondary nodes and use the following mqsiaddbrokerinstance command.
     mqsiaddbrokerinstance MyBroker –e /MQHA/MyBroker/
    where:
    • MyBroker is the name of the broker.
    • /MQHA/MyBroker/ is the directory for your shared resource.
  3. To start a broker, you can use one of the following script files:
    hamqsi_start_broker
    #!/bin/ksh
    # Module:
    #   hamqsi_start_broker
    #
    # Args:
    #   BROKER = name of broker to start
    #
    # Description:
    #   This script attempts to start the MQSI Broker
    #
    #   Runs as the userid which runs broker, and must have 
    #   the user's environment (i.e. invoke from "su - $MQUSER ..")
    #
    
    BROKER=$1
    
    if [ -z "$BROKER" ]
    then
      echo "hamqsi_start_broker: ERROR! No Broker name supplied"
      echo "   Usage: hamqsi_start_broker <BROKER>" 
      exit 1
    fi
    
    # Ensure that the broker is not already running. In this test
    # we look for any broker-related processes, which might have
    # been left around after a previous failure. Any that remain
    # must now be terminated. This is a brutal means of mopping 
    # up broker processes.
    # We stop the processes in the following order:
    #   bipservice       - first so it cannot issue restarts
    #   bipbroker        - next for same reason
    #   biphttplistener
    #   startDataFlowEngine
    #   DataFlowEngine  - last
    #
    echo "hamqsi_start_broker: Ensure $BROKER not already running"
    for process in bipservice bipbroker biphttplistener startDataFlowEngine DataFlowEngine
    do
      # Output of kill redirected to /dev/null in case no processes
      ps -ef | grep "$process $BROKER" | grep -v grep | \
         awk '{print $2}'| xargs kill -9 > /dev/null 2>&1
    done
    
    
    # Start the Broker 
    echo "hamqsi_start_broker: Start Broker " $BROKER
    mqsistart $BROKER > /dev/null 2>&1
    if [ $? -ne "0" ]
    then 
      echo "hamqsi_start_broker: Bad result from mqsistart for $BROKER"
      exit 1
    fi
    
    # Check to see if the broker service has started. This loop 
    # uses a fixed online timeout of approx. 10 seconds.
    TIMED_OUT=yes
    i=0
    while [ $i -lt 10 ]
    do
      # Check for Broker start. We look for bipservice and 
      # bipbroker to be running; there might be no message flows
      # deployed.
      # Look to see whether bipservice is running
      cnt=`ps -ef | grep "bipservice $BROKER" | grep -v grep | wc -l`
      if [ $cnt -gt 0 ]
      then
        # Look to see whether bipbroker is running
        cnt=`ps -ef | grep "bipbroker $BROKER" | grep -v grep | wc -l`
        if [ $cnt -gt 0 ]
        then
          # Broker is online
          echo "hamqsi_start_broker: ${BROKER} is running"
          TIMED_OUT=no
          break  # out of timing loop
        fi
      fi
      # Manage the loop counter
      i=`expr $i + 1`
      sleep 1
    done
    
    # Report error if broker failed to start in time
    if [ ${TIMED_OUT} = "yes" ]
    then 
      echo "hamqsi_start_broker: Broker service failed to start: " $BROKER
      exit 1
    fi
    
    exit 0
    hamqsi_start_broker_as
    #
    #!/bin/ksh
    # Module:
    #   hamqsi_start_broker_as
    #
    # Args:
    #   broker = broker name
    #   qm     = name of broker queue manager
    #   mquser = user account under which QM and Broker are run
    #
    # Description:
    #   Starting an MQSI Broker requires the following services:
    #   (1) The MQSeries Queue Manager which supports the Broker  
    #   (2) The MQSI Broker service 
    #   This script provides a single source to initiate the required 
    #   services in sequence. 
    #  
    #   Queue Manager:
    #   This script uses the strmqm script supplied by MQSeries V7
    #  
    #   Broker:
    #   This script then invokes the hamqsi_start_broker script which 
    #   checks that the broker is fully stopped and then starts it.
    #
    #   The hamqsi_start_broker_as script should be run as root.
    
    
    
    # Check running as root
    if [ `id -u`  -ne 0 ]
    then
      echo "Must be running as root"
      exit 1
    fi
    
     
    BROKER=$1
    QM=$2
    MQUSER=$3
    
    # Check all parameters exist
    
    if [ -z "$BROKER" ]
    then
      echo "hamqsi_start_broker_as: ERROR! No Broker name supplied"
      echo "  Usage: hamqsi_start_broker_as <BROKER> <QM> <MQUSER>"
      exit 1
    fi
    
    if [ -z "$QM" ]
    then
      echo "hamqsi_start_broker_as: ERROR! No queue manager name supplied"
      echo "  Usage: hamqsi_start_broker_as <BROKER> <QM> <MQUSER>"
      exit 1
    fi
    
    if [ -z "$MQUSER" ]
    then
      echo "hamqsi_start_broker_as: ERROR! No Userid supplied"
      echo "  Usage: hamqsi_start_broker_as <BROKER> <QM> <MQUSER>"
      exit 1
    fi
    
    # ------------------------------------------------------------------- 
    # Start the Queue Manager 
    #
    echo "hamqsi_start_broker_as: Start Queue manager " $QM 
    su $MQUSER -c "/opt/mqm/bin/strmqm $QM"
    rc=$?
    if [ $rc -ne 0 ]
    then
      echo "hamqsi_start_broker_as: Could not start the queue manager"
      exit $rc
    fi
    
    # ------------------------------------------------------------------- 
    # Start the Broker
    #
    # Ensure that the Broker is not already running and start the Broker 
    su - $MQUSER -c "/MQHA/bin/hamqsi_start_broker $BROKER"
    rc=$?
    if [ $rc -ne 0 ]
    then
      echo "hamqsi_start_broker_as: Could not start the broker"
      exit $rc
    fi
    
    exit $rc
  4. To stop a broker, you can use one of the following script files:
    hamqsi_stop_broker
    #!/bin/ksh
    # Module:
    #   hamqsi_stop_broker
    #
    # Args:
    #   broker = name of broker
    #   timeout = max time to allow for each phase of termination
    #
    # Description:
    #   This script stops the broker, forcibly if necessary.
    #   The script should be run by the user account under which 
    #   the broker is run, including environment. 
    
    BROKER=$1
    TIMEOUT=$2
    
    if [ -z "$BROKER" ]
    then
      echo "hamqsi_stop_broker: ERROR! No broker name supplied"
      echo "   Usage: hamqsi_stop_broker <BROKER> <TIMEOUT>"
      exit 1
    fi
    
    if [ -z "$TIMEOUT" ]
    then
      echo "hamqsi_stop_broker: ERROR! No timeout supplied"
      echo "   Usage: hamqsi_stop_broker <BROKER> <TIMEOUT>"
      exit 1
    fi
    
    for severity in normal immediate terminate
    do
      # Issue the stop method in the background - we don't
      # want to risk having it hang us up, indefinitely. We
      # want to be able to concurrently run a TIMEOUT timer
      # to give up on the attempt, and try a more forceful 
      # stop. If the kill version fails then there is nothing 
      # more we can do here anyway.
      
      echo "hamqsi_stop_broker: Attempting ${severity} stop of ${BROKER}"
      case $severity in
    
      normal)
        # Minimum severity of stop is to issue mqsistop
        mqsistop $BROKER > /dev/null 2>&1 &
        ;;
    
      immediate)
        # This is an immediate stop.
        mqsistop $BROKER -i > /dev/null 2>&1 &
        ;;
    
      terminate)
        # This is a brutal means of mopping up Broker processes.
        # We stop the processes in the following order:
        #   bipservice       - first so it cannot issue restarts
        #   bipbroker        - next for same reason
        #   biphttplistener
        #   startDataFlowEngine
        #   DataFlowEngine  - last
        for process in bipservice bipbroker biphttplistener startDataFlowEngine DataFlowEngine 
        do
          # Output of kill redirected to /dev/null in case no processes
          ps -ef | grep "$process $BROKER" | grep -v grep | \
            awk '{print $2}'| xargs kill -9 > /dev/null 2>&1
        done
        ;;
    
      esac
    
      echo "hamqsi_stop_broker: Waiting for ${severity} stop of ${BROKER} to complete"
      TIMED_OUT=yes
      SECONDS=0
      while (( $SECONDS < ${TIMEOUT} ))
      do
        # See whether there are any broker processes still running 
        cnt=`ps -ef | \
          grep -E "bipservice $BROKER|bipbroker $BROKER|startDataFlowEngine $BROKER|DataFlowEngine $BROKER|biphttplistener $BROKER" | \
          grep -v grep | wc -l`
        if [ $cnt -gt 0 ]
        then
          # It's still running...wait for timeout
          sleep 1 # loop granularity
        else
          # It's stopped, as desired
          echo "${BROKER} has stopped"
          TIMED_OUT=no
          break # out of while ..offline timeout loop
        fi
      done # timeout loop
    
      if [ ${TIMED_OUT} = "yes" ]
      then
        continue        # to next level of urgency
      else
        break           # instance is stopped, job is done
      fi
    
    done # next level of urgency
    
    if [ ${TIMED_OUT} = "no" ]
    then
      echo "hamqsi_stop_broker: Completed"
      exit 0
    else
      echo "hamqsi_stop_broker: Completed with errors"
      exit 1
    fi 
    hamqsi_stop_broker_as
    #!/bin/ksh
    # Module:
    #   hamqsi_stop_broker_as
    #
    # Arguments are:
    #   broker = name of broker 
    #   qm     = name of broker queue manager
    #   mquser = user account under which QM and broker run
    #   timeout = max time to allow each phase of stop processing
    #
    # Description:
    #   This script stops the Broker, Queue Manager in that sequence.
    #  
    #   Broker:
    #   The script invokes the hamqsi_stop_broker script to stop the 
    #   broker, which checks that the broker is fully stopped.
    #  
    #   Queue Manager:
    #   This script uses the strmqm script supplied by MQSeries V7 
    #  
    #   The hamqsi_stop_broker_as script should be run as root. 
    
    
    # Check running as root
    if [ `id -u`  -ne 0 ]
    then
      echo "Must be running as root"
      exit 1
    fi
    
     
    BROKER=$1
    QM=$2
    MQUSER=$3
    TIMEOUT=$4
    
    # Check all parameters
    
    if [ -z "$BROKER" ]
    then
      echo "hamqsi_stop_broker_as: ERROR! No Broker name supplied"
      echo "   Usage: hamqsi_stop_broker_as <BROKER> <QM> <MQUSER> <TIMEOUT>"
      exit 1
    fi
    
    if [ -z "$QM" ]
    then
      echo "hamqsi_stop_broker_as: ERROR! No queue manager name supplied"
      echo "   Usage: hamqsi_stop_broker_as <BROKER> <QM> <MQUSER> <TIMEOUT>"
      exit 1
    fi
    
    if [ -z "$MQUSER" ]
    then
      echo "hamqsi_stop_broker_as: ERROR! No userid supplied"
      echo "   Usage: hamqsi_stop_broker_as <BROKER> <QM> <MQUSER> <TIMEOUT>"
      exit 1
    fi
    
    if [ -z "$TIMEOUT" ]
    then
      echo "hamsi_stop_broker_as: ERROR! No Timeout value supplied"
      echo "   Usage: hamqsi_stop_broker_as <BROKER> <QM> <MQUSER> <TIMEOUT>"
     exit 1
    fi
    
    
    METHOD_STATUS="OK"
    
    # ------------------------------------------------------------------- 
    # Stop the BROKER
    #
    echo "hamqsi_stop_broker_as: Stop Broker " $BROKER
    su - $MQUSER -c "/MQHA/bin/hamqsi_stop_broker $BROKER $TIMEOUT"
    if [ $? -ne "0" ]
    then
      # Even if the above operation failed, just report and then continue by 
      # stopping other components
      echo "hamqsi_stop_broker_as: Attempt to stop broker $BROKER failed"
      METHOD_STATUS="Error"
    fi
    
    # ------------------------------------------------------------------- 
    # Stop the Queue Manager, using script from MQ V7
    #
    echo "hamqsi_stop_broker_as: Stop Queue Manager $QM"
    su $MQUSER -c "/opt/mqm/bin/endmqm -i $QM"
    if [ $? -ne "0" ]
    then
      # Even if the above operation failed, just report and then continue by 
      # stopping other components
      echo "hamqsi_stop_broker_as: Attempt to stop queue manager $QM failed"
      METHOD_STATUS="Error"
    fi
    
    if [ ${METHOD_STATUS} = "OK" ]
    then
      exit 0
    else
      echo "hamqsi_stop_broker_as: Completed with errors"
      exit 1
    fi
  5. To monitor a broker, you can use the following script file that checks only for the existence of the main broker processes and provides a successful return code if they are found:
    hamqsi_monitor_broker_as
    #!/bin/ksh
    # Module:
    #   hamqsi_monitor_broker_as
    #
    # Args:
    #   BROKER = name of broker in AppServer
    #   QM     = name of queue manager in AppServer
    #   MQUSER = userid under which queue manager and broker run
    # 
    # Description:
    #   This is the application monitor script used with HACMP/ES. It 
    #   needs to be invoked by a parameter-less wrapper script because
    #   HACMP does not allow parameters to be passed to application
    #   monitor scripts.
    #  
    #   This hamqsi_monitor_broker_as script is run as root, and uses 
    #   su as needed to monitor the 3 components of the application server.
    #  
    #   This script is tolerant of a queue manager that is still in
    #   startup. If the queue manager is still starting this application 
    #   monitor script will exit with 0 - which indicates
    #   to HACMP that there's nothing wrong. This is to allow for
    #   startup time for the queue manager which might exceed the 
    #   Stabilisation Interval set for the Application Monitor in HACMP/ES.
    #    
    #  
    # Exit codes:
    #   0  => Broker & QM are all running OK or starting
    #   >0 => One or more components are not responding.
    #
    
    # Check running as root
    if [ `id -u`  -ne 0 ]
    then
      echo "Must be running as root"
      exit 1
    fi
    
    BROKER=$1
    QM=$2
    MQUSER=$3
    
    # Check the parameters
    
    if [ -z "$BROKER" ]
    then
      echo "hamqsi_monitor_broker_as: ERROR! No broker name supplied"
      exit 1
    fi
    
    if [ -z "$QM" ]
    then
      echo "hamqsi_monitor_broker_as: ERROR! No queue manager name supplied"
      exit 1
    fi
    
    if [ -z "$MQUSER" ]
    then
      echo "hamqsi_monitor_broker_as: ERROR! No mquser supplied"
      exit 1
    fi
    
    # Use a state variable to reflect the state of components as they
    # are tested. Valid values are "stopped", "starting" and "started"
    # Initialise it to "stopped" for safety. 
    STATE="stopped"
    
    # ------------------------------------------------------------------
    # Check that the queue manager is running or starting.
    #
    su - $MQUSER -c "echo 'ping qmgr' | runmqsc ${QM}" > /dev/null 2>&1
    pingresult=$?
    # pingresult will be 0 on success; non-zero on error (man runmqsc)
    if [ $pingresult -eq 0 ]
    then 
      # ping succeeded
      echo "hamqsi_monitor_broker_as: Queue Manager ${QM} is responsive"
      STATE="started"
    else 
      # ping failed
      # Don't condemn the QM immediately, it might be in startup.
      # The following regexp includes a space and a tab, so use tab-friendly
      # editors.
      srchstr=" $QM[  ]*$"
      cnt=`ps -ef | grep strmqm | grep "$srchstr" | grep -v grep \
                    | awk '{print $2}' | wc -l`
      if [ $cnt -gt 0 ]
      then
        # It appears that QM is still starting up, tolerate
        echo "hamqsi_monitor_broker_as: Queue Manager ${QM} is starting"
        STATE="starting"
      else
        # There is no sign of QM start process
        echo "hamqsi_monitor_broker_as: Queue Manager ${QM} is not responsive"
        STATE="stopped"
      fi
    fi
    
    
    # Decide whether to continue or to exit
    case $STATE in
      stopped)
        echo "hamqsi_monitor_broker_as: Queue manager ($QM) is not running correctly"
        exit 1  
        ;;
      starting)
        echo "hamqsi_monitor_broker_as: Queue manager ($QM) is starting"
        echo "hamqsi_monitor_broker_as: WARNING - Stabilisation Interval might be too short"
        echo "hamqsi_monitor_broker_as: WARNING - No test of broker $BROKER will be conducted"
        exit 0  
        ;;
      started)
        echo "hamqsi_monitor_broker_as: Queue manager ($QM) is running"
        continue 
        ;;
    esac
    
    # ------------------------------------------------------------------
    # Check the MQSI Broker is running 
    # 
    # Re-initialise STATE for safety
    STATE="stopped"
    #
    # The broker runs as a process called bipservice which is responsible
    # for starting and re-starting the admin agent process (bipbroker). 
    # The bipbroker is responsible for starting any DataFlowEngines. The 
    # bipbroker starts the DataFlowEngines using the wrapper script 
    # startDataFlowEngine. If no integration servers have been assigned to 
    # the broker there will be no DataFlowEngine processes. There should 
    # always be a bipservice and bipbroker process pair. This monitor 
    # script only tests for bipservice, because bipservice should restart 
    # bipbroker if necessary - the monitor script should not attempt to 
    # restart bipbroker and it might be premature to report an absence 
    # of a bipbroker as a failure.
    #
    cnt=`ps -ef | grep "bipservice $BROKER" | grep -v grep | wc -l`
    if [ $cnt -eq 0 ]
    then 
      echo "hamqsi_monitor_broker_as: MQSI Broker $BROKER is not running"
      STATE="stopped"
    else
      echo "hamqsi_monitor_broker_as: MQSI Broker $BROKER is running" 
      STATE="started"
    fi
    
    # Decide how to exit
    case $STATE in
      stopped)
        echo "hamqsi_monitor_broker_as: Broker ($BROKER) is not running correctly"
        exit 1  
        ;;
      started)
        echo "hamqsi_monitor_broker_as: Broker ($BROKER) is running"
        exit 0 
       ;;
    esac 
    If you require more information than that supplied by the preceding example, you can code your monitor to do the following actions:
    • Subscribe to IBM Integration Bus accounting and statistics, and analyze the results.
    • Put a dummy message through the broker and analyze the results.
  6. Before you delete the broker on the primary node, you must delete any brokers on the standby nodes. To delete a broker, use the mqsiremovebrokerinstance command on the secondary nodes, and the mqsideletebroker command on the primary node.

For further information about configuring WebSphere MQ with a high availability manager, refer to the WebSphere MQ Version 7 product documentation online.

See the:
  • addmqinf command
  • dspmqinf command
  • rmvmqinf. command
and the -md option on the crtmqm command.

be13730_.htm | Last updated Friday, 21 July 2017