简体   繁体   English

队列中的MQGET大消息(> 4MB)导致错误2010

[英]MQGET big message ( > 4MB) from the queue results in error 2010

I am trying to receive the message from the queue using ANSI-C and MQGET function. 我正在尝试使用ANSI-C和MQGET函数从队列接收消息。 The problem is that I always get error 2010 (MQRC_DATA_LENGTH_ERROR). 问题是我总是收到错误2010(MQRC_DATA_LENGTH_ERROR)。

I found out that this error concerns parameter 7 of the MQGET call (DataLength). 我发现此错误涉及MQGET调用(DataLength)的参数7。 The message on my queue has 7157460 bytes. 我的队列上的消息有7157460字节。 The channel I am using for MQGET has the "Maximum message length" set to 104857600 (as well as the queue holding the message). 我用于MQGET的通道的“最大消息长度”设置为104857600(以及保存消息的队列)。

I am even using the MQGET from this example: http://www.capitalware.biz/dl/code/c/msg2file.zip 我什至在以下示例中使用MQGET: http : //www.capitalware.biz/dl/code/c/msg2file.zip

And I still end up with error 2010. What am I doing wrong? 而且我仍然遇到错误2010。我在做什么错? Should I somehow increase the maximum size of the message in MQSERVER environment variable? 我应该以某种方式增加MQSERVER环境变量中消息的最大大小吗?

MQGET call: MQGET调用:

/* ... */
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                       */

I've got it! 我懂了! The answer is to use MQCONNX call to connect to queue manager. 答案是使用MQCONNX调用连接到队列管理器。

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不应用于传输大消息。 MQ File Transfer Edition is one of the solutions then. MQ File Transfer Edition是当时的解决方案之一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM