ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Installation/Configuration Support » MQ Script to create queue in multiple environment

Post new topic  Reply to topic
 MQ Script to create queue in multiple environment « View previous topic :: View next topic » 
Author Message
anil kumar
PostPosted: Wed Feb 19, 2020 11:14 pm    Post subject: MQ Script to create queue in multiple environment Reply with quote

Voyager

Joined: 22 Jan 2017
Posts: 97
Location: India

Dear all,

I'm looking for direction/pointers on scripts to create MQ objects (Q's preferably).

let's say we have two environments staging, Live where I want to create a script so that when a call the script it should create a queue in both stagings queue manager and Live manager.

I know that we can create queue's in any queue manager by running MQSC on that local cmd but what I want is to create a queue in a remote queue manager using MQSC script.

please excuse me if this was already discussed in the forum and point out that discussion thread for reference.

oops, I posted in the wrong forum I think, Moderator move this right forum, please.
Back to top
View user's profile Send private message
hughson
PostPosted: Thu Feb 20, 2020 1:57 am    Post subject: Reply with quote

Padawan

Joined: 09 May 2013
Posts: 1914
Location: Bay of Plenty, New Zealand

I will just preface this reply by saying that this is a solution using a tool we sell here at MQGem. You might be interested to see what it does.

You can use MQSCX to do what you require. Here is a little example script. You pass in the command string to the function "dupe" and it connects to each queue manager in turn and then runs the command in the "cmd" variable.

Code:
func dupe(cmd)
  =conn qm(<@QMgr1>)
  @cmd
  =conn qm(<@QMgr2>)
  @cmd
endfunc

@QMgr1 = "QM1"
@QMgr2 = "QM2"

dupe("DEFINE QLOCAL(DUPED.Q)")


Thanks for listening
Cheers,
Morag
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
tczielke
PostPosted: Thu Feb 20, 2020 7:36 am    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 939
Location: Illinois, USA

I think it was at MQ v8, but runmqsc now supports a -c option to connect as a client to a remote queue manager.
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Thu Feb 20, 2020 9:06 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9394
Location: US: west coast, almost. Otherwise, enroute.

tczielke wrote:
I think it was at MQ v8, but runmqsc now supports a -c option to connect as a client to a remote queue manager.

... and you could write a shell script, passing as arguments the name(s) of the destination qmgrs, and passing as a file the MQSC commands to define objects.
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
tczielke
PostPosted: Thu Feb 20, 2020 9:19 am    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 939
Location: Illinois, USA

bruce2359 wrote:
tczielke wrote:
I think it was at MQ v8, but runmqsc now supports a -c option to connect as a client to a remote queue manager.

... and you could write a shell script, passing as arguments the name(s) of the destination qmgrs, and passing as a file the MQSC commands to define objects.


Kind of like mqsc-qmgrs in the MH06 supportpac.

Code:

#!/bin/bash
#
# NOTES:
# 1) mqsc-qmgrs requires an input of a queue manager group and a unique identifier text.
#    A queue manager group contains a list of queue managers. The queue manager groups must also be defined near the top of the script.
#    The unique identifier text allows multiple users to run mqsc-qmgrs in the same working directory. For this doc, we will assume TIMZ is used.
#    Example: mqsc-qmgrs ALL TIMZ
#
# 2) mqsc-qmgrs must be executed in a directory that includes the file mqsc-qmgrs-TIMZ-input. This file will include the runmqsc commands to execute.
#    Example: mqsc-qmgrs-TIMZ-input might include the following:
#    DIS Q(*) ALL
#    DIS QC(*) ALL
#
# 3) mqsc-qmgrs will produce many temporary output files that will start with mqsc-qmgrs-TIMZ-output* in the current working directory (CWD). 
#
# 4) mqsc-qmgrs will produce a file in the CWD called mqsc-qmgrs-TIMZ-output-all, which includes all the runmqsc output from the queue manager group appended together.
#
# 5) mqsc-qmgrs will produce a file in the CWD called mqsc-qmgrs-TIMZ-output-all-1LS, which has the individual results put into one line.  This 1LS file is helpful for doing greps.
#    Example:  If the following lines was returned in mqsc-qmgrs-TIMZ-output-all for queue manager QM1:
#    AMQ8414: Display Channel details.
#       CHANNEL(CL.2S.SERVER1)                  CHLTYPE(CLUSRCVR)
#       ALTDATE(2016-03-11)                     ALTTIME(02.08.00)
#       BATCHHB(1000)                           BATCHINT(0)     
#   
#    then the following one line would appear in the mqsc-qmgrs-TIMZ-output-all-1LS file:
#    QM1. AMQ8414: Display Channel details.  CHANNEL(CL.2S.SERVER1)              CHLTYPE(CLUSRCVR)  ALTDATE(2016-03-11)                     ALTTIME(02.08.00)  BATCHHB(1000)
#


# Define qmgr groups here
ALL="QM1 \
     QM2 \
     QM3 \
     QM4 \
     QM5 \
     QM6"

TEST="QM1 \
      QM2 \
      QM3"

PROD="QM4 \
      QM5 \
      QM6"

# enforce a queue manager group is the first command line argument
if [ -z "$1" ];then
  echo "Qmgr group argument 1 required!"
  exit 1
fi

eval QMGR_GROUPS=\$$1

if [ A"$QMGR_GROUPS" = A ];then
  echo "$1 is not a defined group!"
  exit 1
fi

# enforce a unique identifier text for the second command line argument
if [ -z "$2" ];then
  echo "Unique Identifier argument 2 required!"
  exit 1
fi

if [ ! -f mqsc-qmgrs-$2-input ]; then
  echo mqsc-qmgrs-$2-input must exist in current working directory!
  exit 1
fi

PID=$$
rm mqsc-qmgrs-$2-output*

echo runmqsc commands that will be run against queue manager group $1 are:
cat mqsc-qmgrs-$2-input

# execute in parallel runmqsc -c against qmgrs in our qmgr group
echo Initiating runmqsc calls for queue managers in group $1
for QMGR in $QMGR_GROUPS
  do
    runmqsc -c $QMGR < mqsc-qmgrs-$2-input > mqsc-qmgrs-$2-output$QMGR$PID.txt &
    WAIT_PIDS=$WAIT_PIDS" "$!
  done

# wait for all the invocations of runmqsc -c to end
echo Waiting for all runmqsc invocations to end
wait $WAIT_PIDS

# collect all the output from runmqsc -c into one file
echo Collect all runmqsc output into mqsc-qmgrs-$2-output-all
for QMGR in $QMGR_GROUPS
  do
    cat mqsc-qmgrs-$2-output$QMGR$PID.txt >> mqsc-qmgrs-$2-output-all
    rm mqsc-qmgrs-$2-output$QMGR$PID.txt
  done

# create another 1LS file that has all the individual results in one line records.  This allows an easier way for users to grep results
echo Create another file mqsc-qmgrs-$2-output-all-1LS that has all the individual results in one line records
HoldTx="";QMGR="";
while read LineTx;
  do
    # We have encountered a new result. Print out what we had parsed for
    # the previous result, a delimitter line, and then reset HoldTx
    if [ A"${LineTx:0:3}" = AAMQ -o A"${LineTx:0:3}" = ACSQ ];then
      echo "$QMGR $HoldTx";
      for ((i=0;i<150;i++));
        do
          printf =;
        done;
      echo;
      HoldTx="";
    fi;
    # We have encountered a new queue manager. Print out what we had parsed for
    # the previous result, a delimitter line, and reset HoldTx, and grab new queue manager
    if [ A"${LineTx:0:31}" = A"Starting MQSC for queue manager" ];then
      echo "$QMGR $HoldTx";
      for ((i=0;i<150;i++));
        do
          printf =;
        done;
      echo;
      HoldTx="";
      QMGR=${LineTx:32:48};
    fi;
    # store current line in our HoldTx variable
    HoldTx=$HoldTx${LineTx:0:${#LineTx}}"  ";
  done < mqsc-qmgrs-$2-output-all > mqsc-qmgrs-$2-output-all-1LS; echo "$QMGR $HoldTx" >> mqsc-qmgrs-$2-output-all-1LS

echo Finished!

_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Thu Feb 20, 2020 11:15 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9394
Location: US: west coast, almost. Otherwise, enroute.

Yes, something like that.
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
anil kumar
PostPosted: Mon Feb 24, 2020 2:29 am    Post subject: Thanks for the replies. Reply with quote

Voyager

Joined: 22 Jan 2017
Posts: 97
Location: India

Many thanks to everyone, for replying.

I will try to take this provided solution as a reference to my requirement.

we were looking for a homegrown solution instead of tools so wanted to do it on our own.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Installation/Configuration Support » MQ Script to create queue in multiple environment
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.