Skip to content

middleware_mq

Andrea Paolini edited this page Dec 15, 2022 · 2 revisions

IBM MQ

Formerly knonw as Websphere MQ (formerly known as MQ Series)

Limits

User

You could need to raise some limits for the mqm user/group. Try with:

@mqm     soft stack  unlimited

in a /etc/security/limits.d/mqm.conf file (see limits.conf man page).

System

You may need to raise some of the kernel limits (i.e. semaphores)

To check for the right values you can use the mqconfig script provided by IBM.

Reason codes

Here's a list of MQ7 Reason Codes

Recipes

Manage a QM

Start the QM

strmqm <QUEUE_MANAGER>

Stop the QM

endmqm <QUEUE_MANAGER>

List all the defined QMs

dspmq

Start the command line console

runmqsc <QUEUE_MANAGER>

Create a new Queue Manager

Create the QM

crtmqm -u SYSTEM.DEAD.LETTER.QUEUE <QUEUE_MANAGER>

Create channel and listener

Via runmqsc:

DEFINE CHANNEL(<CHANNEL_NAME>) CHLTYPE(SVRCONN) MCAUSER('mqm')
DEFINE LISTENER(<LISTENER_NAME>) TRPTYPE(TCP) CONTROL(QMGR) PORT(141XX)
START LISTENER(<LISTENER_NAME>)

Delete a Queue Manager

endmqm <QUEUE_MANAGER>
dltmqm <QUEUE_MANAGER>

Show used ports

echo "DISPLAY LISTENER(*) PORT" |\
runmqsc <QUEUE_MANAGER>

Show active connections

MQ 6.0

echo "DISPLAY CONN(*) APPLTAG CONNAME" | runmqsc <QUEUE_MANAGER> | grep "APPLTAG"

Increase the number of channels

Edit qm.ini (in /var/mqm/qmgrs/QM_NAME/) and add the following stanza:

Channels:
MaxChannels=nn

The default is 100.

Enable TCP Keepalive

Edit qm.ini (in /var/mqm/qmgrs/QUEUE_MANAGER/) and add the following stanza:

TCP:
KeepAlive=Yes

Note that TCP keepalive support must be activated at OS/kernel level.

Show QM status

It also shows the total number of active connections.

DISPLAY QMSTATUS ALL

Show the status of a queue

DISPLAY QSTATUS(<QUEUE>)

Clean a QM

...excluding the system objects.

With solaris use nawk(1): /usr/xpg4/bin/awk

Empty all the queues

MYQM=MYQUEUEMGR
AWK=awk
echo "DISPLAY QLOCAL(*) WHERE (CURDEPTH GT 0)" |\
runmqsc $MYQM |\
$AWK '/QUEUE\(SYSTEM./{next} /QUEUE/{sub("QUEUE","QLOCAL"); print "CLEAR",$1} END {print "END"}' |\
sed -e "s/(/(\'/" -e "s/)/\')/" |\
runmqsc $MYQM
...forcing rollback

If you have "stubborn" messages you cannot delete (part of a distributed transaction, and now in-doubt) and you need to force the rollback:

  • Disable the listener
ALTER LISTENER(LISTENERNAME) TRPTYPE(TCP) CONTROL(MANUAL)
  • Stop and restart QM
  • Rollback the pending transactions
dspmqtrn -m $MYQM | awk '/^AMQ7056/ {print $4}' |\
  sed 's/\.//' | while read tr ; do
    rsvmqtrn -m $MYQM -b $tr
  done
  • Reenable the listener
ALTER LISTENER(LISTENERNAME) TRPTYPE(TCP) CONTROL(QMGR)
  • Stop and start QM

Delete all QLOCAL and QALIAS

MYQM=MYQUEUEMGR
AWK=awk
echo "DISPLAY QLOCAL(*)" |\
runmqsc $MYQM |\
$AWK '/QUEUE\(SYSTEM./{next} /QUEUE/{sub("QUEUE","QLOCAL"); print "DELETE",$1} END {print "END"}' |\
sed -e "s/(/(\'/" -e "s/)/\')/" |\
runmqsc $MYQM
echo "DISPLAY QALIAS(*)" |\
runmqsc $MYQM |\
$AWK '/QUEUE\(SYSTEM./{next} /QUEUE/{sub("QUEUE","QALIAS"); print "DELETE",$1} END {print "END"}' |\
sed -e "s/(/(\'/" -e "s/)/\')/" |\
runmqsc $MYQM

Distributed Queueing (remote queues)

On QM1

DEFINE QREMOTE(QREM) +
   RNAME(QLOC) +
   RQMNAME(QM2) +
   XMITQ(QM2.XMITQ)

DEFINE QLOCAL(QM2.XMITQ) +
   INITQ(SYSTEM.CHANNEL.INITQ) +
   USAGE (XMITQ) +
   TRIGGER +
   TRIGDATA(QM1.TO.QM2) +
   TRIGTYPE(FIRST)

DEFINE CHANNEL(QM1.TO.QM2) +
   CHLTYPE(SDR) +
   TRPTYPE(TCP) +
   XMITQ(QM2.XMITQ) +
   CONNAME('1.2.3.4(1234)')

On QM2

DEFINE QLOCAL (QLOC)

DEFINE CHANNEL(QM1.TO.QM2) +
   CHLTYPE(RCVR) +
   TRPTYPE(TCP)

Start MQ Explorer

Start the graphical Eclipse-based interface with

strmqcfg

Disable channel authentication - MQ 7.5

For a specific channel:

SET CHLAUTH(MYCHANNEL) TYPE(BLOCKUSER) USERLIST('*NOACCESS')

For the whole QM:

ALTER QMGR CHLAUTH(DISABLED)

Useful paths

Configuration files:

/var/mqm/qmgrs/<QUEUE_MANAGER>/qm.ini

Error logs:

/var/mqm/qmgrs/<QUEUE_MANAGER>/errors/AMQ*.LOG

Clone this wiki locally