MQPUT1 - Put one message
The MQPUT1 call puts one message on a queue, or distribution list, or to a topic.
The queue, distribution list, or topic does not need to be open.
Syntax
MQPUT1 (Hconn, ObjDesc, MsgDesc, PutMsgOpts, BufferLength, Buffer, CompCode, Reason)
Parameters
- Hconn
- Type: MQHCONN - input
This handle represents the connection to the queue manager. The value of Hconn was returned by a previous MQCONN or MQCONNX call.
On z/OS® for CICS® applications the MQCONN call can be omitted, and the following value specified for Hconn :- MQHC_DEF_HCONN
- Default connection handle.
- ObjDesc
- Type: MQOD - input/output
This is a structure that identifies the queue to which the message is added, or the topic to which the message is published. See MQOD - Object descriptor for details.
If the structure is a queue, the user must be authorized to open the queue for output. The queue must not be a model queue.
- MsgDesc
- Type: MQMD - input/output
This structure describes the attributes of the message being sent, and receives feedback information after the put request is complete. See MQMD - Message descriptor for details.
If the application provides a version-1 MQMD, the message data can be prefixed with an MQMDE structure to specify values for the fields that exist in the version-2 MQMD but not the version-1. Set the Format field in the MQMD to MQFMT_MD_EXTENSION to indicate that an MQMDE is present. See MQMDE - Message descriptor extension for more details.
The application does not need to provide an MQMD structure if a valid message handle is supplied in the MsgHandle field of the MQGMO structure or in the OriginalMsgHandle or NewMsgHandle fields of the MQPMO structure. If nothing is provided in one of these fields, the descriptor of the message is taken from the descriptor associated with the message handles.
- PutMsgOpts
- Type: MQPMO - input/output
See MQPMO - Put-message options for details.
- BufferLength
- Type: MQLONG - input
The length of the message in Buffer. Zero is valid, and indicates that the message contains no application data. The upper limit depends on various factors; see MQPUT - Put message for the description of the BufferLength parameter.
- Buffer
- Type: MQBYTExBufferLength - input
This is a buffer containing the application message data to be sent. Align the buffer on a boundary appropriate to the nature of the data in the message. 4-byte alignment is suitable for most messages (including messages containing IBM MQ header structures), but some messages might require more stringent alignment. For example, a message containing a 64-bit binary integer might require 8-byte alignment.
If Buffer contains character or numeric data, set the CodedCharSetId and Encoding fields in the MsgDesc parameter to the values appropriate to the data; this enables the receiver of the message to convert the data (if necessary) to the character set and encoding used by the receiver.
Note: All the other parameters on the MQPUT1 call must be in the character set and encoding of the local queue manager (given by the CodedCharSetId queue manager attribute and MQENC_NATIVE).In the C programming language, the parameter is declared as a pointer-to-void; the address of any type of data can be specified as the parameter.
If the BufferLength parameter is zero, Buffer is not referred to; in this case, the parameter address passed by programs written in C or System/390 assembler can be null.
- CompCode
- Type: MQLONG - output
The completion code; it is one of the following:
- MQCC_OK
- Successful completion.
- MQCC_WARNING
- Warning (partial completion).
- MQCC_FAILED
- Call failed.
- Reason
- Type: MQLONG - output
The reason code qualifying CompCode.
If CompCode is MQCC_OK:- MQRC_NONE
- (0, X'000') No reason to report.
If CompCode is MQCC_WARNING:
- MQRC_MULTIPLE_REASONS
- (2136, X'858') Multiple reason codes returned.
- MQRC_INCOMPLETE_GROUP
- (2241, X'8C1') Message group not complete.
- MQRC_INCOMPLETE_MSG
- (2242, X'8C2') Logical message not complete.
- MQRC_PRIORITY_EXCEEDS_MAXIMUM
- (2049, X'801') Message Priority exceeds maximum value supported.
- MQRC_UNKNOWN_REPORT_OPTION
- (2104, X'838') Report options in message descriptor not recognized.
If CompCode is MQCC_FAILED:
- MQRC_ADAPTER_NOT_AVAILABLE
- (2204, X'89C') Adapter not available.
- MQRC_ADAPTER_SERV_LOAD_ERROR
- (2130, X'852') Unable to load adapter service module.
- MQRC_ALIAS_BASE_Q_TYPE_ERROR
- (2001, X'7D1') Alias base queue not a valid type.
- MQRC_API_EXIT_ERROR
- (2374, X'946') API exit failed.
- MQRC_API_EXIT_LOAD_ERROR
- (2183, X'887') Unable to load API exit.
- MQRC_ASID_MISMATCH
- (2157, X'86D') Primary and home ASIDs differ.
- MQRC_BACKED_OUT
- (2003, X'7D3') Unit of work backed out.
- MQRC_BUFFER_ERROR
- (2004, X'7D4') Buffer parameter not valid.
- MQRC_BUFFER_LENGTH_ERROR
- (2005, X'7D5') Buffer length parameter not valid.
- MQRC_CALL_IN_PROGRESS
- (2219, X'8AB') MQI call entered before previous call complete.
- MQRC_CF_NOT_AVAILABLE
- (2345, X'929') coupling facility not available.
- MQRC_CF_STRUC_AUTH_FAILED
- (2348, X'92C') Coupling-facility structure authorization check failed.
- MQRC_CF_STRUC_ERROR
- (2349, X'92D') Coupling-facility structure not valid.
- MQRC_CF_STRUC_FAILED
- (2373, X'945') Coupling-facility structure failed.
- MQRC_CF_STRUC_IN_USE
- (2346, X'92A') Coupling-facility structure in use.
- MQRC_CF_STRUC_LIST_HDR_IN_USE
- (2347, X'92B') Coupling-facility structure list-header in use.
- MQRC_CFGR_ERROR
- (2416, X'970') PCF group parameter structure MQCFGR in the message data is not valid.
- MQRC_CFH_ERROR
- (2235, X'8BB') PCF header structure not valid.
- MQRC_CFIF_ERROR
- (2414, X'96E') PCF integer filter parameter structure in the message data is not valid.
- MQRC_CFIL_ERROR
- (2236, X'8BC') PCF integer list parameter structure or PCIF*64 integer list parameter structure not valid.
- MQRC_CFIN_ERROR
- (2237, X'8BD') PCF integer parameter structure or PCIF*64 integer parameter structure not valid.
- MQRC_CFSF_ERROR
- (2415, X'96F') PCF string filter parameter structure in the message data is not valid.
- MQRC_CFSL_ERROR
- (2238, X'8BE') PCF string list parameter structure not valid.
- MQRC_CFST_ERROR
- (2239, X'8BF') PCF string parameter structure not valid.
- MQRC_CICS_WAIT_FAILED
- (2140, X'85C') Wait request rejected by CICS.
- MQRC_CLUSTER_EXIT_ERROR
- (2266, X'8DA') Cluster workload exit failed.
- MQRC_CLUSTER_RESOLUTION_ERROR
- (2189, X'88D') Cluster name resolution failed.
- MQRC_CLUSTER_RESOURCE_ERROR
- (2269, X'8DD') Cluster resource error.
- MQRC_COD_NOT_VALID_FOR_XCF_Q
- (2106, X'83A') COD report option not valid for XCF queue.
- MQRC_CONNECTION_BROKEN
- (2009, X'7D9') Connection to queue manager lost.
- MQRC_CONNECTION_NOT_AUTHORIZED
- (2217, X'8A9') Not authorized for connection.
- MQRC_CONNECTION_QUIESCING
- (2202, X'89A') Connection quiescing.
- MQRC_CONNECTION_STOPPING
- (2203, X'89B') Connection shutting down.
- MQRC_CONTENT_ERROR
- 2554 (X'09FA') Message content could not be parsed to determine whether the message can be delivered to a subscriber with an extended message selector.
- MQRC_CONTEXT_HANDLE_ERROR
- (2097, X'831') Queue handle referred to does not save context.
- MQRC_CONTEXT_NOT_AVAILABLE
- (2098, X'832') Context not available for queue handle referred to.
- MQRC_DATA_LENGTH_ERROR
- (2010, X'7DA') Data length parameter not valid.
- MQRC_DB2_NOT_AVAILABLE
- (2342, X'926') Db2® subsystem not available.
- MQRC_DEF_XMIT_Q_TYPE_ERROR
- (2198, X'896') Default transmission queue not local.
- MQRC_DEF_XMIT_Q_USAGE_ERROR
- (2199, X'897') Default transmission queue usage error.
- MQRC_DH_ERROR
- (2135, X'857') Distribution header structure not valid.
- MQRC_DLH_ERROR
- (2141, X'85D') Dead letter header structure not valid.
- MQRC_EPH_ERROR
- (2420, X'974') Embedded PCF structure not valid.
- MQRC_EXPIRY_ERROR
- (2013, X'7DD') Expiry time not valid.
- MQRC_FEEDBACK_ERROR
- (2014, X'7DE') Feedback code not valid.
- MQRC_GLOBAL_UOW_CONFLICT
- (2351, X'92F') Global units of work conflict.
- MQRC_GROUP_ID_ERROR
- (2258, X'8D2') Group identifier not valid.
- MQRC_HANDLE_IN_USE_FOR_UOW
- (2353, X'931') Handle in use for global unit of work.
- MQRC_HANDLE_NOT_AVAILABLE
- (2017, X'7E1') No more handles available.
- MQRC_HCONN_ERROR
- (2018, X'7E2') Connection handle not valid.
- MQRC_HEADER_ERROR
- (2142, X'85E') IBM MQ header structure not valid.
- MQRC_IIH_ERROR
- (2148, X'864') IMS information header structure not valid.
- MQRC_LOCAL_UOW_CONFLICT
- (2352, X'930') Global unit of work conflicts with local unit of work.
- MQRC_MD_ERROR
- (2026, X'7EA') Message descriptor not valid.
- MQRC_MDE_ERROR
- (2248, X'8C8') Message descriptor extension not valid.
- MQRC_MISSING_REPLY_TO_Q
- (2027, X'7EB') Missing reply-to queue.
- MQRC_MISSING_WIH
- (2332, X'91C') Message data does not begin with MQWIH.
- MQRC_MSG_FLAGS_ERROR
- (2249, X'8C9') Message flags not valid.
- MQRC_MSG_SEQ_NUMBER_ERROR
- (2250, X'8CA') Message sequence number not valid.
- MQRC_MSG_TOO_BIG_FOR_Q
- (2030, X'7EE') Message length greater than maximum for queue.
- MQRC_MSG_TOO_BIG_FOR_Q_MGR
- (2031, X'7EF') Message length greater than maximum for queue manager.
- MQRC_MSG_TYPE_ERROR
- (2029, X'7ED') Message type in message descriptor not valid.
- MQRC_MULTIPLE_REASONS
- (2136, X'858') Multiple reason codes returned.
- MQRC_NO_DESTINATIONS_AVAILABLE
- (2270, X'8DE') No destination queues available.
- MQRC_NOT_AUTHORIZED
- (2035, X'7F3') Not authorized for access.
- MQRC_OBJECT_DAMAGED
- (2101, X'835') Object damaged.
- MQRC_OBJECT_IN_USE
- (2042, X'7FA') Object already open with conflicting options.
- MQRC_OBJECT_LEVEL_INCOMPATIBLE
- (2360, X'938') Object level not compatible.
- MQRC_OBJECT_NAME_ERROR
- (2152, X'868') Object name not valid.
- MQRC_OBJECT_NOT_UNIQUE
- (2343, X'927') Object not unique.
- MQRC_OBJECT_Q_MGR_NAME_ERROR
- (2153, X'869') Object queue manager name not valid.
- MQRC_OBJECT_RECORDS_ERROR
- (2155, X'86B') Object records not valid.
- MQRC_OBJECT_TYPE_ERROR
- (2043, X'7FB') Object type not valid.
- MQRC_OD_ERROR
- (2044, X'7FC') Object descriptor structure not valid.
- MQRC_OFFSET_ERROR
- (2251, X'8CB') Message segment offset not valid.
- MQRC_OPTIONS_ERROR
- (2046, X'7FE') Options not valid or not consistent.
- MQRC_ORIGINAL_LENGTH_ERROR
- (2252, X'8CC') Original length not valid.
- MQRC_PAGESET_ERROR
- (2193, X'891') Error accessing page-set data set.
- MQRC_PAGESET_FULL
- (2192, X'890') External storage medium is full.
- MQRC_PCF_ERROR
- (2149, X'865') PCF structures not valid.
- MQRC_PERSISTENCE_ERROR
- (2047, X'7FF') Persistence not valid.
- MQRC_PERSISTENT_NOT_ALLOWED
- (2048, X'800') Queue does not support persistent messages.
- MQRC_PMO_ERROR
- (2173, X'87D') Put-message options structure not valid.
- MQRC_PMO_RECORD_FLAGS_ERROR
- (2158, X'86E') Put message record flags not valid.
- MQRC_PRIORITY_ERROR
- (2050, X'802') Message priority not valid.
- MQRC_PUBLICATION_FAILURE
- (2502, X'9C6') The publication has not been delivered to any of the subscribers.
- MQRC_PUT_INHIBITED
- (2051, X'803') Put calls inhibited for the queue.
- MQRC_PUT_MSG_RECORDS_ERROR
- (2159, X'86F') Put message records not valid.
- MQRC_Q_DELETED
- (2052, X'804') Queue has been deleted.
- MQRC_Q_FULL
- (2053, X'805') Queue already contains maximum number of messages.
- MQRC_Q_MGR_NAME_ERROR
- (2058, X'80A') Queue manager name not valid or not known.
- MQRC_Q_MGR_NOT_AVAILABLE
- (2059, X'80B') Queue manager not available for connection.
- MQRC_Q_MGR_QUIESCING
- (2161, X'871') Queue manager quiescing.
- MQRC_Q_MGR_STOPPING
- (2162, X'872') Queue manager shutting down.
- MQRC_Q_SPACE_NOT_AVAILABLE
- (2056, X'808') No space available on disk for queue.
- MQRC_Q_TYPE_ERROR
- (2057, X'809') Queue type not valid.
- MQRC_RECS_PRESENT_ERROR
- (2154, X'86A') Number of records present not valid.
- MQRC_REMOTE_Q_NAME_ERROR
- (2184, X'888') Remote queue name not valid.
- MQRC_REPORT_OPTIONS_ERROR
- (2061, X'80D') Report options in message descriptor not valid.
- MQRC_RESOURCE_PROBLEM
- (2102, X'836') Insufficient system resources available.
- MQRC_RESPONSE_RECORDS_ERROR
- (2156, X'86C') Response records not valid.
- MQRC_RFH_ERROR
- (2334, X'91E') MQRFH or MQRFH2 structure not valid.
- MQRC_RMH_ERROR
- (2220, X'8AC') Reference message header structure not valid.
- MQRC_SECURITY_ERROR
- (2063, X'80F') Security error occurred.
- MQRC_SEGMENT_LENGTH_ZERO
- (2253, X'8CD') Length of data in message segment is zero.
- MQRC_SELECTION_NOT_AVAILABLE
- 2551 (X'09F7') A possible subscriber for the publication exists, but the queue manager cannot check whether to send the publication to the subscriber.
- MQRC_STOPPED_BY_CLUSTER_EXIT
- (2188, X'88C') Call rejected by cluster workload exit.
- MQRC_STORAGE_CLASS_ERROR
- (2105, X'839') Storage class error.
- MQRC_STORAGE_MEDIUM_FULL
- (2192, X'890') External storage medium is full.
- MQRC_STORAGE_NOT_AVAILABLE
- (2071, X'817') Insufficient storage available.
- MQRC_SUPPRESSED_BY_EXIT
- (2109, X'83D') Call suppressed by exit program.
- MQRC_SYNCPOINT_LIMIT_REACHED
- (2024, X'7E8') No more messages can be handled within current unit of work.
- MQRC_SYNCPOINT_NOT_AVAILABLE
- (2072, X'818') Syncpoint support not available.
- MQRC_TM_ERROR
- (2265, X'8D9') Trigger message structure not valid.
- MQRC_TMC_ERROR
- (2191, X'88F') Character trigger message structure not valid.
- MQRC_UNEXPECTED_ERROR
- (2195, X'893') Unexpected error occurred.
- MQRC_UNKNOWN_ALIAS_BASE_Q
- (2082, X'822') Unknown alias base queue.
- MQRC_UNKNOWN_DEF_XMIT_Q
- (2197, X'895') Unknown default transmission queue.
- MQRC_UNKNOWN_OBJECT_NAME
- (2085, X'825') Unknown object name.
- MQRC_UNKNOWN_OBJECT_Q_MGR
- (2086, X'826') Unknown object queue manager.
- MQRC_UNKNOWN_REMOTE_Q_MGR
- (2087, X'827') Unknown remote queue manager.
- MQRC_UNKNOWN_XMIT_Q
- (2196, X'894') Unknown transmission queue.
- MQRC_UOW_ENLISTMENT_ERROR
- (2354, X'932') Enlistment in global unit of work failed.
- MQRC_UOW_MIX_NOT_SUPPORTED
- (2355, X'933') Mixture of unit-of-work calls not supported.
- MQRC_UOW_NOT_AVAILABLE
- (2255, X'8CF') Unit of work not available for the queue manager to use.
- MQRC_WIH_ERROR
- (2333, X'91D') MQWIH structure not valid.
- MQRC_WRONG_CF_LEVEL
- (2366, X'93E') Coupling-facility structure is wrong level.
- MQRC_WRONG_MD_VERSION
- (2257, X'8D1') Wrong version of MQMD supplied.
- MQRC_XMIT_Q_TYPE_ERROR
- (2091, X'82B') Transmission queue not local.
- MQRC_XMIT_Q_USAGE_ERROR
- (2092, X'82C') Transmission queue with wrong usage.
- MQRC_XQH_ERROR
- (2260, X'8D4') Transmission queue header structure not valid.
For detailed information about these codes, see Reason codes.
Usage notes
- Both the MQPUT and MQPUT1 calls can be used to put messages on a queue; which call to use depends on the circumstances:
- Use the MQPUT call to place multiple messages on the same queue.
An MQOPEN call specifying the MQOO_OUTPUT option is issued first, followed by one or more MQPUT requests to add messages to the queue; finally the queue is closed with an MQCLOSE call. This gives better performance than repeated use of the MQPUT1 call.
- Use the MQPUT1 call to put only one message on a queue.
This call encapsulates the MQOPEN, MQPUT, and MQCLOSE calls into a single call, minimizing the number of calls that must be issued.
- Use the MQPUT call to place multiple messages on the same queue.
- If an application puts a sequence of messages on the same queue without using message groups, the order of those messages is preserved if certain conditions are satisfied. However, in most environments the MQPUT1 call does not satisfy these conditions, and so does not preserve message order. The MQPUT call must be used instead in these environments. See MQPUT usage notes for details.
- The MQPUT1 call can be used to put messages to distribution lists. For general information about this, see the usage notes for the MQOPEN and MQPUT calls.
Distribution lists are supported in the following environments: AIX , HP-UX, IBM i, Solaris, Linux , Windows, plus IBM MQ clients connected to these systems.
The following differences apply when using the MQPUT1 call:- If the application provides MQRR response records, they must be provided using the MQOD structure; they cannot be provided using the MQPMO structure.
- The reason code MQRC_OPEN_FAILED is never returned by MQPUT1 in the response records; if a queue fails to open, the response record for that queue contains the reason code resulting from the open operation.
If an open operation for a queue succeeds with a completion code of MQCC_WARNING, the completion code and reason code in the response record for that queue are replaced by the completion and reason codes resulting from the put operation.
As with the MQOPEN and MQPUT calls, the queue manager sets the response records (if provided) only when the outcome of the call is not the same for all queues in the distribution list; this is indicated by the call completing with reason code MQRC_MULTIPLE_REASONS.
- If the MQPUT1 call is used to put a message on a cluster queue, the call behaves as though MQOO_BIND_NOT_FIXED had been specified on the MQOPEN call.
- If a message is put with one or more IBM MQ header structures at the beginning of the application message data, the queue manager performs certain checks on the header structures to verify that they are valid. For more information about this, see the usage notes for the MQPUT call.
- If more than one of the warning situations arise (see the CompCode parameter), the reason code returned is the first one in the following list that applies:
- MQRC_MULTIPLE_REASONS
- MQRC_INCOMPLETE_MSG
- MQRC_INCOMPLETE_GROUP
- MQRC_PRIORITY_EXCEEDS_MAXIMUM or MQRC_UNKNOWN_REPORT_OPTION
- For the Visual Basic programming language, the following points apply:
- If the size of the Buffer parameter is less than the length specified by the BufferLength parameter, the call fails with reason code MQRC_BUFFER_LENGTH_ERROR.
- The Buffer parameter is declared as being of type String. If the data to be placed on the queue is not of type String, use the
MQPUT1Any call in place of MQPUT1.
The MQPUT1Any call has the same parameters as the MQPUT1 call, except that the Buffer parameter is declared as being of type Any, allowing any type of data to be placed on the queue. However, this means that Buffer cannot be checked to ensure that it is at least BufferLength bytes in size.
- When an MQPUT1 call is issued with MQPMO_SYNCPOINT, the default behavior changes, so that the put operation is completed asynchronously. This might cause a change in the behavior of some applications that rely on certain fields in the MQOD and MQMD structures being returned, but which now contain undefined values. An application can specify MQPMO_SYNC_RESPONSE to ensure that the put operation is performed synchronously and that all the appropriate field values are completed.
C invocation
MQPUT1 (Hconn, &ObjDesc, &MsgDesc, &PutMsgOpts, BufferLength, Buffer, &CompCode, &Reason);Declare the parameters as follows:
MQHCONN Hconn; /* Connection handle */ MQOD ObjDesc; /* Object descriptor */ MQMD MsgDesc; /* Message descriptor */ MQPMO PutMsgOpts; /* Options that control the action of MQPUT1 */ MQLONG BufferLength; /* Length of the message in Buffer */ MQBYTE Buffer[n]; /* Message data */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Reason code qualifying CompCode */
COBOL invocation
CALL 'MQPUT1' USING HCONN, OBJDESC, MSGDESC, PUTMSGOPTS, BUFFERLENGTH, BUFFER, COMPCODE, REASON.Declare the parameters as follows:
** Connection handle 01 HCONN PIC S9(9) BINARY. ** Object descriptor 01 OBJDESC. COPY CMQODV. ** Message descriptor 01 MSGDESC. COPY CMQMDV. ** Options that control the action of MQPUT1 01 PUTMSGOPTS. COPY CMQPMOV. ** Length of the message in BUFFER 01 BUFFERLENGTH PIC S9(9) BINARY. ** Message data 01 BUFFER PIC X(n). ** Completion code 01 COMPCODE PIC S9(9) BINARY. ** Reason code qualifying COMPCODE 01 REASON PIC S9(9) BINARY.
PL/I invocation
call MQPUT1 (Hconn, ObjDesc, MsgDesc, PutMsgOpts, BufferLength, Buffer, CompCode, Reason);Declare the parameters as follows:
dcl Hconn fixed bin(31); /* Connection handle */ dcl ObjDesc like MQOD; /* Object descriptor */ dcl MsgDesc like MQMD; /* Message descriptor */ dcl PutMsgOpts like MQPMO; /* Options that control the action of MQPUT1 */ dcl BufferLength fixed bin(31); /* Length of the message in Buffer */ dcl Buffer char(n); /* Message data */ dcl CompCode fixed bin(31); /* Completion code */ dcl Reason fixed bin(31); /* Reason code qualifying CompCode */
High Level Assembler invocation
CALL MQPUT1,(HCONN,OBJDESC,MSGDESC,PUTMSGOPTS,BUFFERLENGTH, X BUFFER,COMPCODE,REASON)Declare the parameters as follows:
HCONN DS F Connection handle OBJDESC CMQODA , Object descriptor MSGDESC CMQMDA , Message descriptor PUTMSGOPTS CMQPMOA , Options that control the action of MQPUT1 BUFFERLENGTH DS F Length of the message in BUFFER BUFFER DS CL(n) Message data COMPCODE DS F Completion code REASON DS F Reason code qualifying COMPCODE
Visual Basic invocation
MQPUT1 Hconn, ObjDesc, MsgDesc, PutMsgOpts, BufferLength, Buffer, CompCode, ReasonDeclare the parameters as follows:
Dim Hconn As Long 'Connection handle' Dim ObjDesc As MQOD 'Object descriptor' Dim MsgDesc As MQMD 'Message descriptor' Dim PutMsgOpts As MQPMO 'Options that control the action of MQPUT1' Dim BufferLength As Long 'Length of the message in Buffer' Dim Buffer As String 'Message data' Dim CompCode As Long 'Completion code' Dim Reason As Long 'Reason code qualifying CompCode'