在c中,我尝试从安装了MQ服务器的同一个Unix服务器连接到MQ服务器并且它正在连接并将消息放入队列但是如果我尝试从MQ客户端(来自另一个开发)那么同样的事情它抛出错误信息:
MQCONN以原因代码2195结束。
以下是样本:
// Libraries included
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cmqc.h>
#include <cmqxc.h>
以下是我声明和定义为连接到MQ Server的变量: //变量声明。
MQCNO Connect_options = {MQCNO_DEFAULT}; /* MQCONNX options */
MQCD ClientConn = {MQCD_CLIENT_CONN_DEFAULT}; /* Client connection channel */
MQHCONN Hcon; /* connection handle */
MQHOBJ Hobj; /* object handle */
MQLONG CompCode; /* completion code */
MQLONG Reason; /* reason code */
MQOD od = {MQOD_DEFAULT}; /* Object Descriptor */
MQMD md = {MQMD_DEFAULT}; /* Message Descriptor */
MQPMO pmo = {MQPMO_DEFAULT}; /* put message options */
MQLONG O_options; /* MQOPEN options */
MQLONG C_options; /* MQCLOSE options */
char QMgrName[MQ_Q_MGR_NAME_LENGTH+1];
char QName[MQ_Q_NAME_LENGTH+1];
char channelName[MQ_CHANNEL_NAME_LENGTH+1];
char hostname[1024];
MQLONG buflen; /* buffer length */
char TempBuf[1024] = "MQPutdata:This is a simple test message.";
以下是为调用MQCONNX函数定义的其他变量: printf(“MQPutdata started \ n”);
strncpy(QMgrName, argv[1], MQ_Q_MGR_NAME_LENGTH);
QMgrName[MQ_Q_MGR_NAME_LENGTH] = '\0';
strncpy(channelName, argv[2], MQ_CHANNEL_NAME_LENGTH);
channelName[MQ_CHANNEL_NAME_LENGTH] = '\0';
strncpy(hostname, argv[3], 1023);
hostname[1023] = '\0';
strncpy(QName, argv[4], MQ_Q_NAME_LENGTH);
QMgrName[MQ_Q_NAME_LENGTH] = '\0';
这里我为MQCONNX函数设置了所需的值
strncpy(ClientConn.ConnectionName,
hostname,
MQ_CONN_NAME_LENGTH);
strncpy(ClientConn.ChannelName,
channelName,
MQ_CHANNEL_NAME_LENGTH);
现在我以这种方式调用MQCONNX函数:
Connect_options.ClientConnPtr = &ClientConn;
Connect_options.Version = MQCNO_VERSION_2;
MQCONNX(QMgrName,
&Connect_options,
&Hcon,
&CompCode,
&Reason);
我使用以下optpions编译但没有任何工作:
1. cc -H -I/export/home/aupadhya/mqm/inc -L/opt/mqm/lib64 -o MQPutdata.exe MQPutdata.c -lmqic
2. cc -H -I/export/home/aupadhya/mqm/inc -L/opt/mqm/lib64 -o MQPutdata.exe MQPutdata.c -lmqic -lmqmcs -lsocket
3. cc -H -I/export/home/aupadhya/mqm/inc -L/opt/mqm/lib64 -o MQPutdata.exe MQPutdata.c -lmqic -lmqmcs -lmqmzse -lsocket