As input to the MQPUT call, you must supply:
The output from the MQPUT call is
If the call completes successfully, it also returns your options structure and your message descriptor structure. The call modifies your options structure to show the name of the queue and the queue manager to which the message was sent. If you request that the queue manager generates a unique value for the identifier of the message you are putting (by specifying binary zero in the MsgId field of the MQMD structure), the call inserts the value in the MsgId field before returning this structure to you. This value must be reset before you issue another MQPUT.
There is a description of the MQPUT call in WebSphere MQ Application Programming Reference.
The following sections describe the information you must supply as input to the MQPUT call.
For the connection handle (Hconn) in CICS on z/OS applications, you can specify the constant MQHC_DEF_HCONN (which has the value zero), or you can use the connection handle returned by the MQCONN or MQCONNX call. For other applications, always use the connection handle returned by the MQCONN or MQCONNX call.
Whatever environment you are working in, use the same queue handle (Hobj) that is returned by the MQOPEN call.
The message descriptor structure (MQMD) is an input/output parameter for the MQPUT and MQPUT1 calls. You use it to define the message you are putting on a queue.
If MQPRI_PRIORITY_AS_Q_DEF or MQPER_PERSISTENCE_AS_Q_DEF is specified for the message and the queue is a cluster queue the values used will be those of the queue the MQPUT resolves to. If that queue is disabled for MQPUT the call will fail. See WebSphere MQ Queue Manager Clusters for more information.
There is an introduction to the message properties that MQMD describes in Chapter 3, WebSphere MQ messages, and there is a description of the structure itself in WebSphere MQ Application Programming Reference.
You use the MQPMO (Put Message Option) structure to pass options to the MQPUT and MQPUT1 calls.
The following sections give you help on filling in the fields of this structure. There is a description of the structure in WebSphere MQ Application Programming Reference.
The fields of the structure include:
These fields are described below.
If you leave the Options field set to the default value (MQPMO_NONE), the message you put has default context information associated with it.
Also, the way that the call operates with syncpoints is determined by the platform. The syncpoint control default is 'yes' in z/OS; for other platforms, it is 'no'.
For an introduction to message context, see Message context. For information about using the MQPMO structure to control the context information in a message, see Controlling context information.
The MQPMO can also accommodate fields required for distribution lists (see Distribution lists). If you wish to use this facility, Version 2 of the MQPMO structure is used. This includes the following fields:
The value you enter can be the same as the number of Object Records provided at MQOPEN. However, if the value is less than the number of Object Records provided on the MQOPEN call (or if no Put Message Records are provided), the values of the queues that are not defined are taken from the default values provided by the message descriptor. Also, if the value is greater than the number of Object Records provided, the excess Put Message Records are ignored.
You are recommended to do one of the following:
When you have put the message to the queue, MsgId values that the queue manager has created become available in the MQPMRs; you can use these to identify which destination is associated with each report or reply.
For a full description of Put Message Records (MQPMR) and Response Records (MQRR), see WebSphere MQ Application Programming Reference.
Use the PutMsgRecPtr field to specify a pointer to the first Put Message Record, or the PutMsgRecOffset field to specify the offset of the first Put Message Record. This is the offset from the start of the MQPMO. Depending on the PutMsgRecFields field, enter a nonnull value for either PutMsgRecOffset or PutMsgRecPtr.
Use the ResponseRecPtr field to specify a pointer to the first Response Record, or the ResponseRecOffset field to specify the offset of the first Response Record. This is the offset from the start of the MQPMO structure. Enter a nonnull value for either ResponseRecOffset or ResponseRecPtr.
Additional information for putting to a distribution list (see Distribution lists) is provided in Version 2 of the Put Message Option structure (MQPMR). This is described in WebSphere MQ Application Programming Reference.
Give the address of the buffer that contains your data in the Buffer parameter of the MQPUT call. You can include anything in the data in your messages. The amount of data in the messages, however, affects the performance of the application that is processing them.
The maximum size of the data is determined by:
The MaxMsgLength attribute of the queue manager holds the size of message that the queue manager can process. This has a default of 4 MB (1 MB=1048576 bytes), or 100 MB for all MQSeries or WebSphere MQ Version 5 products.
To determine the value of this attribute, use the MQINQ call on the queue manager object. For large messages, you can change this value.
The MaxMsgLength attribute of a queue determines the maximum size of message you can put on the queue. If you attempt to put a message with a size larger than the value of this attribute, your MQPUT call fails. If you are putting a message on a remote queue, the maximum size of message that you can successfully put is determined by the MaxMsgLength attribute of the remote queue, of any intermediate transmission queues that the message is put on along the route to its destination, and of the channels used.
For an MQPUT operation, the size of the message must be smaller than or equal to the MaxMsgLength attribute of both the queue and the queue manager. The values of these attributes are independent, but you are recommended to set the MaxMsgLength of the queue to a value less than or equal to that of the queue manager.
WebSphere MQ adds header information to messages in the following circumstances:
These structures are described in WebSphere MQ Application Programming Reference.
If your messages are of the maximum size allowed for these queues, the addition of these headers means that the put operations fail because the messages are now too big. To reduce the possibility of the put operations failing:
The attributes for the queue manager and the message queuing constants are described in WebSphere MQ Application Programming Reference.
For information on how undelivered messages are handled in a distributed queuing environment, see WebSphere MQ Intercommunication.