Reputation: 2340
I am trying to receive the message from the queue using ANSI-C and MQGET function. The problem is that I always get error 2010 (MQRC_DATA_LENGTH_ERROR).
I found out that this error concerns parameter 7 of the MQGET call (DataLength). The message on my queue has 7157460 bytes. The channel I am using for MQGET has the "Maximum message length" set to 104857600 (as well as the queue holding the message).
I am even using the MQGET from this example: http://www.capitalware.biz/dl/code/c/msg2file.zip
And I still end up with error 2010. What am I doing wrong? Should I somehow increase the maximum size of the message in MQSERVER environment variable?
MQGET call:
/* ... */
MQLONG messlen; /* message length received */
MQGET(Hcon, /* connection handle */
Hobj, /* object handle */
&md, /* message descriptor */
&gmo, /* get message options */
buflen, /* pBuffer length */
pBuffer, /* pointer to message buffer */
&messlen, /* message length */
&CompCode, /* completion code */
&Reason); /* reason code */
Upvotes: 4
Views: 8929
Reputation: 49
for nodejs use below code.
const mq = require('ibmmq')
const MQC = mq.MQC
// Create default MQCNO structure
const cno = new mq.MQCNO()
// Add authentication via the MQCSP structure
var csp = new mq.MQCSP()
csp.UserId = process.env.MQ_USER
csp.Password = process.env.MQ_PASSWORD
// This line allows use of the userid/password
cno.SecurityParms = csp
// And use the MQCD to programmatically connect as a client
// First force the client mode
cno.Options |= MQC.MQCNO_CLIENT_BINDING
// And then fill in relevant fields for the MQCD
var cd = new mq.MQCD()
cd.ConnectionName = `${process.env.MQ_HOST}(${process.env.MQ_PORT})`
cd.ChannelName = `${process.env.MQ_CHANNEL}`
// Set the maximum message length to 100 MB (104857600 bytes)
cd.MaxMsgLength = 104857600; // 100 MB
Upvotes: 0
Reputation: 2340
I've got it! The answer is to use MQCONNX call to connect to queue manager.
Example:
#include <cmqxc.h>
/* ... */
MQCNO mqcno = {MQCNO_DEFAULT} ; /* Connection options */
MQCD mqcd = {MQCD_CLIENT_CONN_DEFAULT}; /* Channel Defs */
/* ... */
mqcd.MaxMsgLength = 104857600L; /* 100 MB */
MQCONNX(mQueueManager.Name,
&mqcno,
&mQueueManager.ConnectionHandle,
&mQueueManager.CompletionCode,
&mQueueManager.ReasonCode);
It worked like a charm!
But please remember - if you find yourself needing to increase the maximum message size - think twice. There is probably something wrong with the design. In another words - MQ should not be used for transferring big messages. MQ File Transfer Edition is one of the solutions then.
Upvotes: 3