The two most recent versions of QLOAD have added a feature to allow you to upload messages onto queues using QLOAD even when the file is not in the standard QLOAD format (i.e. it wasn’t from a QLOAD unload).
QLOAD can now use files containing message data where each message is delimited from the next message in some way. This could mean that there are tags, or separator characters between the messages or even, the simplest example, that each message is on a new line.
Message text 1 Message text 2 Message text 3
msgs.txt: A file with one message on each line
To load the above file onto a queue, with one message taken from the text on each line, you would use the following QLOAD invocation.
qload -m MQG1 -o Q1 -f msgs.txt -Cd -nn
You haven’t specified any delimiters on this command, and that is because QLOAD assumes that new line is the delimiter you want if you don’t say otherwise. The -n switch is what says you want to parse a delimited file, and saying -nn tells QLOAD not to include the delimiters (in this case the new line character) as part of the message text. You could be explicit about the delimiter in use with the following command.
qload -m MQG1 -o Q1 -f msgs.txt -Cd -nn -ne:"\n"
In our next example, we have a file with some character separators.
data.txt: A file with single character separators
To load the above file onto a queue, with one message taken from the text on each line, you would use the following QLOAD invocation. Note that you must have the final character delimiter for all four messages to be found.
qload -m MQG1 -o Q1 -f data.txt -Cd -nn -ne:/
Helpfully, QLOAD will output a message to tell you how many messages it has found with a prompt before you continue, to help you spot when it hasn’t found all the messages you hoped it would find.
4 messages found in the file. Do you want to continue? (y/n)
If you have explicit start and end delimiters, then you can start to jump past data in the file that is not part of a message, which is handy for commentary. For example with the following file:-
Here are a few messages [message1][message2] and then here are a few more [message3] [message4] [message5]
info.txt: A file with start and end delimiters, and comments
To load the above file onto a queue, ignoring the comments and only pulling out the message data between the square brackets, you would use the following command.
qload -m MQG1 -o Q1 -f info.txt -Cd -nns:[ -nne:]
There is also a short-hand you can use when you have delimiters of the same length, as shown in the next command.
qload -m MQG1 -o Q1 -f info.txt -Cd -nnd:
Delimiters don’t have to be single characters, nor do they have to be excluded from the message. You may well have message content that is naturally delimited, for example XML messages. The outside tag of the structure of your XML message may well be all you need as a delimiter.
<message> <date>12 Jun 2019</date> <priority>High</priority> <department>AG75</department> <code>HT7228</code> </message> <message> <date>29 Aug 2019</date> <priority>Medium</priority> <department>AL23</department> <code>LL3460</code> </message>
xml.txt: A file with XML message data
A file like this where the delimiter is part of the message data can be loaded with the following command.
qload -mMQG1 -oQ1 -f xml.txt -Cd -ni -ns:"<message>" -ne:"</message>"
In this case you cannot use the -nd flag because the delimiters are not of the same length, and you must specify each one individually using the start (-ns) and end (-ne) flags.
If you need to have some message properties added to your message when it is uploaded, this data can also be found are delimited text in your file. Looking again at the XML data example, here we have added some property data to the file.
<usr> <importance dt='i4'>1</importance> </usr> <message> <date>12 Jun 2019</date> <priority>High</priority> <department>AG75</department> <code>HT7228</code> </message> <usr> <importance dt='i4'>2</importance> </usr> <message> <date>29 Aug 2019</date> <priority>Medium</priority> <department>AL23</department> <code>LL3460</code> </message>
xml2.txt: A file with XML message data and message properties
To load this file onto a queue, you now need to provide two sets of delimiters so that QLOAD can know where the message data is and where the property data is.
qload -m MQG1 -o Q1 -f xml2.txt -Cd -nis:"<message>" -nie:"</message>" -nip:"<usr>" -niq:"</usr>"
While it is likely that you will use this second set of delimiters for message properties, that is the <usr> folder in an MQRFH2 header, in fact you can use it to construct any MQRFH2 folder that you require since you provide the complete folder structure.
The new version can be downloaded from the QLOAD Download Page. Any current licensed users of QLOAD can run the new version on their existing licence. If you don’t have a licence and would like to try out QLOAD then send an email to email@example.com and a 1-month trial licence will be sent to you.