In the recent MO71 video which demonstrated exporting your IBM MQ object definitions to files of various formats, you saw various inserts in use in the file names shown.
This post is going expand on that brief mention to show you all the different inserts that can be used and what you end up with when you use them.
All the file inserts are used by prefixing the code with a percent sign.
File names including a date
If you’re exporting all your object definitions on a daily or weekly basis let’s say, it would be very useful to have the file name include the date so that, should you need to recreate the objects, you can easily ensure you’re using the latest one.
|y||Four digit year|
|m||Three character month name e.g. Jan, Feb, Mar|
|d||Two digit day of month|
Using a file name with inserts like QM1_Export_%y%m%d.mqs would result in file names as follows (this being used for a daily automatic export of all objects at 9am):-
File names including a time
If you’re trying to monitor the behaviour of an application, perhaps through a peak time period, or to understand why there’s a backlog of messages at a certain time of day, you might be exporting some specific details, CURDEPTH, IPPROCS and OPPROCS say every 60 seconds. It may well be useful to have the time stamp in the file name in such a case.
|t||Simple time format e.g. 18.14.03|
|H||Two digit hour|
|M||Two digit minutes|
|S||Two digit seconds|
Using a file name with inserts like RequestQ_Usage_%t.mqs would result in file names as follows (this being used for an automatic refresh and export of one queue every 60 seconds):-
However, if you prefer a different time format, you can build it up yourself with the hour, minute and second insert, instead of the above simple time insert.
Using a file name with inserts like RequestQ_Usage_%Hh%Mm%Ss.mqs would result in file names as follows:-
File names with a cyclical index
If you regularly export some data, let’s say the channel status every 30 minutes, whilst trying to track down a network issue, but you don’t want an ever increasing number of files, and instead want to just keep the last 10 exported files, you can use cyclical file names.
|i||Cyclic index number|
To create cyclical file names use inserts like ChannelStatus%i10.mqs would result in file names as follows:-
up to 10, and then the files will be overwritten.
The other inserts available that haven’t been mentioned are as follows:-
|q||Queue manager name|
|D||Three character day of week e.g. Mon, Tue, Wed|
As with any technique, the best way to understand is to try it out yourself, figure out what file names you would use for your exported files. You can download MO71 from the MQGem website and if you don’t currently have a licence, you may email firstname.lastname@example.org to request a trial licence.