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