To control context information, you use the Options field in the MQPMO structure.
If you don't, the queue manager will overwrite context information that may already be in the message descriptor with the identity and context information it has generated for your message. This is the same as specifying the MQPMO_DEFAULT_CONTEXT option. You may want this default context information when you create a new message (for example, when processing user input from an inquiry screen).
If you want no context information associated with your message, use the MQPMO_NO_CONTEXT option.
In general, programs should pass identity context information from message to message around an application until the data reaches its final destination. Programs should change the origin context information each time they change the data. However, applications that want to change or set any context information must have the appropriate level of authority. The queue manager checks this authority when the applications open the queues; they must have authority to use the appropriate context options for the MQOPEN call.
If your application gets a message, processes the data from the message, then puts the changed data into another message (possibly for processing by another application), the application should pass the identity context information from the original message to the new message. You can allow the queue manager to create the origin context information.
To save the context information from the original message, you must use the MQOO_SAVE_ALL_CONTEXT option when you open the queue for getting the message. This is in addition to any other options you use with the MQOPEN call. Note, however, that you cannot save context information if you only browse the message.
When you create the second message, you must:
If your application gets a message, and puts the message data (unchanged) into another message, the application should pass both the identity and the origin context information from the original message to the new message. An example of an application that might do this is a message mover, which moves messages from one queue to another.
Follow the same procedure as for passing identity context, except you use the MQOPEN option MQOO_PASS_ALL_CONTEXT and the put-message option MQPMO_PASS_ALL_CONTEXT.
If you want to set the identity context information for a message, leaving the queue manager to set the origin context information:
If you want to set both the identity and the origin context information for a message:
Appropriate authority is needed for each type of context setting.