MQ provides a sample Dead Letter Queue Handler in /opt/mqm/samp/dlq/ (on Ubuntu). It looks and behaves just like runmqdlq. I think trying to extend it, for example to filter on MSGID or CORRELID would be difficult, and it would be easier to write a small program just to process one message with input queue, and pass filter parameters.
Build it
There are no instructions in the IBM documentation on how to build this. I used the following
- create a directory to contain the code, for example mkdir ~/dlq
- go to this directory cd ~/dlq
- copy the code from MQ cp -r /opt/mqm/samp/dlq/* .
- make the directory rw chmod +w ~/dlq
- install a yacc compiler sudo apt install byacc
- issue the make command make all -f amqodqx.mk
If you get
gcc -m64 -I. -I/opt/mqm/inc -c -o amqodqka.o amqodqka.c
Assembler messages:
Fatal error: can’t create amqodqka.o: Permission denied
Your directory is not read/write. Use the chmod command.
If you get
yacc amqodqma.y
make: yacc: Command not found
You need to install a yacc compiler. I used sudo apt install byacc .
I dont undestand why I got this message, because the build for the yacc files is commented out. It may be there is a default make for yacc.
The YACC ( compiler generator) produces a c file. If you are not changing the keywords, you could rename the .y and .l files, so they are not used, and so use the shipped c files. In this case you will not need the yacc compiler.
Run it
- export ODQ_MSG=amqsdlq.msg This is needed for the message catalog
- ./amqsdlq SYSTEM.PROTECTION.ERROR.QUEUE QMA < /home/colinpaice/mqams/dlq.rul
- for a while it failed with a syntax error in line 1 of the file, I rebuilt it, then suddenly it worked.
- Ctrl-c ended it
- ./amqsdlq ? gave me a segmentation core dump
I changed the make file to build a client
cc -m64 -o amqsdlqc… -lmqic_r
You should ensure you use a TLS channel if you do run this as a client.
Why would it mean changing the program to use a TLS channel?
LikeLike
Good point – brain check.. I was thinking you cannot use MQSERVER and extrapolated
LikeLike
And I don’t even think it is necessary to remind anymore. You can make a client connection using something linked with mqm.lib. Just set MQ_CONNECT_TYPE to CLIENT. See https://community.ibm.com/community/user/integration/blogs/morag-hughson/2017/12/13/ibm-mq-little-gem-30-mq-connect-type
LikeLike
Thank you – I always thought it was poor having to specify which library you need. I’ll tell Hursley, because their build instructions still say
build for client.. –lmqic_r, build for server -lmqm_r. See https://www.ibm.com/docs/en/ibm-mq/9.2?topic=linux-building-32-bit-applications
LikeLike