Cleaning up after your application programmers.

Some people are Application Pros. This is not a compliment – it is short for half an Application Programmer, because they only develop half an application.

Symptoms of this are the application queue depths are high (100 may be high), the queue never becomes empty, or a large msgage for the queue.

Consider an application which sends a request to a backend and expects a response. Normally the response comes back in time, the application gets it, and the reply is deleted.
If there is a delay, the application gets a no-message found (reason 2033), and returns. The reply message arrives a short while later.

  • If the message is non persistent, it should have an expiry interval and will get removed automatically. No problem.
  • If the message is persistent with an expiry interval. This is not good practice. It should either be non persistent with expiry or persistent without expiry.
  • If the message does not have an expiry interval. You need a process to do things with the messages. Select messages older than a certain time, so you do not process the ones which are being processed. The action may be to create a compensating request, or to update a table to remove a “pending” flag in a record, and then to remove the message from the queue.

As a systems programmer or MQ administrator you do not just want to clear the queue – as it is not your data (in case you delete a queue with your pay cheque in it – or other important information). The application owner should have the responsibility for processing the data.

If you have the “Application Pro” you need to help them, by giving them a process to offload old messages.

MQ V8 provides a program dmpmqmsg which unloads (or loads) mq messages from a queue.

MQGEM has a similar product. See here. It has a superset of functions – for example dump all queues with a specified prefix, and create output file names with today’s date in it etc. Have a look – is is worth it!

You could use the IBM version as follows

  • dspmqmsg -m queue manager name
  • -I input queue name (upper case -I for get delete, lower case -i for get browse)
  • -f file name. This should be something like qm_name.Queue_name.Date_time
  • -T1:2:3 select messages older than 1 Day, 2 Hours, 3 Minutes

You need to protect the output file, to restrict who can view it. By default the permissions are -rw-r–r–.

You could encrypt it with

  • openssl enc -AES-256-CBC -in infile -out outfile.enc -pass pass:longpassword
  • rm infile

Zip with a password is better than nothing – but it is relatively insecure.

Changing permissions to “only owner has read” – still allows super users to read the file.

If any messages have been offloaded – you need to raise an alert against the development team a) to tell them about the problem and b) to remind them to get a proper process in place.