MO71 Export File Name Inserts

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.

Insert Effect
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):-
QM1_Export_2015Jan30.mqs
QM1_Export_2015Feb01.mqs
QM1_Export_2015Feb02.mqs

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.

Insert Effect
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):-
RequestQ_Usage_12.30.45.mqs
RequestQ_Usage_12.31.45.mqs
RequestQ_Usage_12.32.45.mqs

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:-
RequestQ_Usage_12h30m45s.mqs
RequestQ_Usage_12h31m45s.mqs
RequestQ_Usage_12h32m45s.mqs

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.

Insert Effect
i Cyclic index number

To create cyclical file names use inserts like ChannelStatus%i10.mqs would result in file names as follows:-
ChannelStatus1.mqs
ChannelStatus2.mqs
ChannelStatus3.mqs

up to 10, and then the files will be overwritten.

Other inserts

The other inserts available that haven’t been mentioned are as follows:-

Insert Effect
q Queue manager name
l Location name
D Three character day of week e.g. Mon, Tue, Wed
% Percent character

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 support@mqgem.com to request a trial licence.

Advertisements

The team at MQGem would love to hear what you think. Leave your comments here.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s