Bootstrap FreeKB - IBM MQ - Update channel using the alter channel command
IBM MQ - Update channel using the alter channel command

Updated:   |  IBM MQ articles

A channel is used to used to make a connection to an IBM MQ queue manager, thus each connection will be associated with a channel.

 

Before using the alter channel command to change a channels value, you will probably want to use the display channel command to display the details of the channel. For example, let's say the channel named CHANNEL01 in the queue manager named MANAGER01 has the following values.

~]# echo "display channel ('CHANNEL01')" | runmqsc MANAGER01
CHANNEL(CHANNEL01)           CHLTYPE(SVRCONN)
ALTDATE(yyyy-mm-dd)          ALTTIME(hh.mm.ss)
CERTLABL( )                  COMPHDR(NONE)
COMPSMG(NONE)                DESCR( )
DISCINT(0)                   HBINT(300)
KAINT(AUTO)                  MAXINST(999999999)
MAXINSTC(999999999)          MAXMSGL(4194304)
MCAUSER(JohnDoe)             MONCHL(QMGR) 
RCVDATA( )                   RCVEXIT( )
SCYDATA( )                   SCYEXIT( )
SENDDATA( )                  SENDEXIT( )
SHARECNV(10)                 SSLCAUTH(REQUIRED)
SSLCIPH( )                   SSLPEER( )
TRPTYPE(TCP)

 

Notice in this example that the DESCR (description) is empty. The alter channel command can be used to change a channels value. In this example, CHANNEL01 is updated to have a description of "Hello World".

AVOID TROUBLE

When a value is a string and contains one or more white spaces, the value must be wrapped in quotes. In this example, Hello World is wrapped in quotes.

echo "alter channel ('CHANNEL01') chltype (SVRCONN) DESCR ('Hello World')" | runmqsc MANAGER01

 

AVOID TROUBLE

When a value is an integer, the value must NOT be wrapped in quotes. In this example, 10000000 is not wrapped in quotes.

echo "alter channel ('CHANNEL01') chltype (SVRCONN) MAXMSGL (10000000)" | runmqsc MANAGER01


If there is some issue with the alert channel command, something like this might be returned. This typically suggests you did not include chltype or you have a syntax error.

AMQ8427I: Valid syntax for the MQSC command:

  ALTER CHANNEL( channel_name )
   CHLTYPE( SDR | SVR | RCVR | RQSTR | CLNTCONN | SVRCONN |
            CLUSSDR | CLUSRCVR | AMQP | MQTT* )
One MQSC command read.
One command has a syntax error.

 

If the channel is successfully updated, the following output should be returned.

AMQ8016I: IBM MQ channel changed.

 

Reissuing the display channel command should show that the channel has been updated. In this example, the channel now has description "Hello World".

~]# echo "display channel ('CHANNEL01')" | runmqsc MANAGER01
CHANNEL(CHANNEL01)           CHLTYPE(SVRCONN)
ALTDATE(yyyy-mm-dd)          ALTTIME(hh.mm.ss)
CERTLABL( )                  COMPHDR(NONE)
COMPSMG(NONE)                DESCR(Hello World)
DISCINT(0)                   HBINT(300)
KAINT(AUTO)                  MAXINST(999999999)
MAXINSTC(999999999)          MAXMSGL(4194304)
MCAUSER(JohnDoe)             MONCHL(QMGR) 
RCVDATA( )                   RCVEXIT( )
SCYDATA( )                   SCYEXIT( )
SENDDATA( )                  SENDEXIT( )
SHARECNV(10)                 SSLCAUTH(REQUIRED)
SSLCIPH( )                   SSLPEER( )
TRPTYPE(TCP)

 

A for loop can be used to loop through all of the channels. Here is an example of how to loop through all of the non SYSTEM channels.

for channel in $(echo "display channel (*)" | runmqsc MANAGER01 | grep -v ^AMQ8414I | grep "CHLTYPE(SVRCONN)" | grep -v SYSTEM | sed 's|^\s*||g' | sed 's|CHANNEL(||g' | sed 's|).*||g'); do echo $channel; done;

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


August 04 2022 by kalpana
I believe the for loop will display all SVRCONN channels, but not alter any channel property. How do we alter the property like DESCR,MAXINSTC for all SVRCONN channels with script. Appreciate your comments and suggestions here.

August 05 2022 by Jeremy (moderator)
Yep, you can replace "echo $channel" in my example for loop with the actual command you want to issue, such as echo "alter channel ('CHANNEL01') chltype (SVRCONN) DESCR ('Hello World')" | runmqsc MANAGER01

August 01 2022 by madhav
It's nice article. What if we want to alter all svrconn channels at one to update the DESCR ('Hello World') or any property. Any script will help, any suggestion on how to alter the DESCR to all channels

August 02 2022 by Jeremy (moderator)
Yep, you can use a for loop. I updated this article with an example for loop.

August 05 2022 by kalpana
Thank you so much for reply and update on below for loop script. I believe this will only alter the channel name CHANNEL01 for QMGR MANAGER01. But i would like to hear how to alter all SVRCONN channels for all Queue managers at once in script. The alter channel command needs a channel name to alter the changes. I tried with alter channel(*) chltype(svrconn) descr("hellow") but didn't work. Any suggestions here ? "echo $channel" in my example for loop with the actual command you want to issue, such as echo "alter channel ('CHANNEL01') chltype (SVRCONN) DESCR ('Hello World')" | runmqsc MANAGER01 Thank You.

Add a Comment


Please enter 5818f1 in the box below so that we can be sure you are a human.