Q) MQGET/MQPUT(1) is reporting MQRC_DATA_LENGTH_ERROR, however the channel, queues and queue manager’s MAXMSGL length is set to 104857600, what’s wrong ?

A) MQRC_DATA_LENGTH_ERROR can be returned to an MQ MQI client program on the MQGET/ MQPUT(1) call, if the BufferLength parameter of an MQGET/MQPUT(1) call exceeds the maximum message size that was negotiated for the client channel. Maximum message size negotiated by the channel depends on MAXMSGL attribute of the channel.

The default value of MAXMSGL is 4MB and it can be set in 4 places in MQ :-
1) On a Queue Manager object
2) On a Queue object
3) On a Channel (SVRCONN/CLNTCONN) object
4) On MQCD structure programmatically

If you have set the MAXMSGL of the first 3 objects to 100MB and still running into MQRC_DATA_LENGTH_ERROR error, your client application could probably be using MQCONNX call and using MQCNO and MQCD. This enables a client application to provide the definition of its client connection channel at run-time without using a client channel table or the MQSERVER environment variable.

Channel specified by the MQCD structure takes priority over any specified by the MQSERVER environment variable and the MQSERVER environment variable takes priority over any client channel definition pointed to by MQCHLLIB and MQCHLTAB. Hence the MAXMSGL set in CLNTCONN/SVRCONN channel will not be considered if MQCONNX and MQCD are used.

While passing the client connection information in MQCONNX, unless the client application explicitly sets the Max Message length the default value of 4194304 will be assumed and the channel uses 4194304 as MaxMessageSz during channel negotiation. Also though you have set 104857600 as MAXMSGL in its corresponding SVRCONN channel, this will be compared with the value of the partner and the actual maximum used is the lower of the two values. Hence MQGET/MQPUT(1) could report MQRC_DATA_LENGTH_ERROR for message that are over 4 MB.

If messages of higher value is required to be transmitted, you have to set the MaxMsgLength of MQCD structure programmatically in client application, as you would be doing for connection name and channel name.

Eg:-

MQCNO Connect_options = {MQCNO_DEFAULT};
MQCD ClientConn = {MQCD_CLIENT_CONN_DEFAULT};

/* Initialise the client channel definition if required */
strncpy(ClientConn.ConnectionName,
p_argConnName,
MQ_CONN_NAME_LENGTH);
strncpy(ClientConn.ChannelName,
p_argChannelName,
MQ_CHANNEL_NAME_LENGTH);

/* Set the MAXMSGL explicitly, else default 4MB will be taken */
ClientConn.MaxMsgLength = 104857600L;

/* Point the MQCNO to the client connection definition */
Connect_options.ClientConnPtr = &ClientConn;

Some points to note:-

1)MAXMSGL has to be large enough for the largest message and it needs to be set for the entire route of the message (i.e) all applicable queue manager, queues, channels and clients.
2)MQRC_DATA_LENGTH_ERROR can be reported even if the message length (Data Length) of the message is lesser than the maximum message size that was negotiated for the client channel. Please note that it is not the message length that MQ considers, it is the BufferLength parameter. Eg: MQRC_DATA_LENGTH_ERROR will be reported if MaxMessageSz is 4MB, BufferLength is 5MB and message length is 3MB.
3)If the MAXMSGL of the queue / queue manager is 4MB ( lesser than the largest message ) and MAXMSGL of channel is 100MB. MQPUT of messages larger than 4MB will be split and stored in the queue, it does not report MQRC_DATA_LENGTH_ERROR.

1 comment on"Troubleshooting MQRC_DATA_LENGTH_ERROR"

  1. […] Troubleshooting MQRC_DATA_LENGTH_ERROR […]

Leave a Reply