Loading Messages with the correct context

One of the benefits of using QLOAD to unload and then reload your messages is that the full MQMD is also saved and restored, so you don’t lose the context fields of your messages. They still show the original putting application and user ID just as before they were unloaded, and the put date and time fields stay the same as well.

What are the context fields?

In case you don’t remember, here’s a quick summary of the MQMD Context fields. There are two sets of context fields, the Identity Context and the Origin Context. It is possible to manipulate just the Identity Context fields or all the fields as we’ll see in a moment.

Identity Context Fields Origin Context Fields
UserIdentifier PutApplType
AccountingToken PutApplName
ApplIdentityData PutDate
  PutTime
  ApplOriginData

If you want a quick refresher on how authorisations work with these fields, check out this Morag’s Quirks blog post.

Manipulating Context fields

By default QLOAD will do the puts when you load messages onto a queue using “Set All Context” which means all the fields that are saved in the unloaded file are put back in the newly loaded up messages.

If you prefer to upload the messages and record new context fields to show that they are from you, then you can tell QLOAD you use a different context option. The following command will set all the context fields to identify QLOAD as the application that put the messages, and the user that is running QLOAD as the User Identifier. This is known as “Default Context” and is indicated using the -Cd flag (Context – default).

qload -m MQG1 -o Q1 -f Q1-messages.qld -Cd

If you want to just keep the identity context fields as they were in the unload file, and have the origin context fields reflect what’s happening now you can use the “Set Identity Context” option, -CI flag (Context – Identity).

qload -m MQG1 -o Q1 -f Q1-messages.qld -CI

Another option that can be very useful is to have all these MQMD fields be exactly as they were when unloaded with the exception of the Put Date and Time fields. This isn’t an MQ option, it’s just something that QLOAD offers you. It uses “Set All Context” and grabs a new timestamp for your Put Date and Time fields just before it puts the message to the queue. You can do this by using the -Ct flag (Context – time).

qload -m MQG1 -o Q1 -f Q1-messages.qld -Ct

This particular option can be very useful if you save off message data to replay in testing scenarios. Everything else stays the same, but the messages reflect the fact that they have been put right now.

There are a number of other context options for when you are moving messages not from a file, but from a queue. These can be found in the QLOAD User Guide, or by reading the QLOAD program help.

qload -C?

QLOAD can be downloaded from our webite. If you don’t have a licence and would like to try out QLOAD then send an email to support@mqgem.com and a 1-month trial licence will be sent to you.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.