【发布时间】:2018-08-21 12:40:18
【问题描述】:
我正在尝试使用 pro*c 语言连接远程 MQ,在连接到 MQ 时我正在使用 MQCONNX 和 MQOPEN 方法,
执行 MQOPEN 方法后,它返回错误 MQRC 2018。
以下是参考代码。
还想知道是否存在任何类型的身份验证问题或服务器级别问题导致此问题,因为使用不同方法的相同代码在连接到本地 MQ 客户端时可以正常工作。
谢谢
int MS_MQ_Open(const char *chr_p_qmname, const char *chr_p_qname,
const char *mode, MQHCONN *Hcon, MQHOBJ *Hobj,
INTL_ENV_DATA_STRUCT_H *p_intlenv_data_struct_h,
DEBUG_INFO_STRUCT_H **l_debug_info_ptr) {
MQOD od = {MQOD_DEFAULT}; /* Object Descriptor */
MQLONG OpenCode; /* MQOPEN completion code */
MQLONG O_options;
MQLONG Reason;
MQLONG CReason;
MQLONG CompCode;
MQCNO mqcno = {MQCNO_DEFAULT}; /* Connection options */
MQCD mqcd = {MQCD_CLIENT_CONN_DEFAULT}; /* Channel Defs */
MQCSP csp = {MQCSP_DEFAULT};
MQCHAR chr_l_qmname[MQ_Q_MGR_NAME_LENGTH];
char userId[50];
char password[50];
strncpy(userId, "XXXXXX", 50);
strncpy(chr_l_qmname, chr_p_qmname, MQ_Q_MGR_NAME_LENGTH);
strncpy(mqcd.ConnectionName, "10.000.00.00(port number)",
MQ_CONN_NAME_LENGTH);
strncpy(mqcd.ChannelName, "SVRCONN", MQ_CHANNEL_NAME_LENGTH);
mqcno.SecurityParmsPtr = &csp;
mqcno.Version = MQCNO_VERSION_5;
csp.AuthenticationType = MQCSP_AUTH_USER_ID_AND_PWD;
csp.CSPUserIdPtr = userId;
csp.CSPUserIdOffset = 0;
csp.CSPUserIdLength = strlen(userId);
strncpy(password, "XXXX", 50);
csp.CSPPasswordPtr = password;
csp.CSPPasswordOffset = 0;
csp.CSPPasswordLength = strlen(password);
mqcno.ClientConnPtr = &mqcd;
mqcno.Version = MQCNO_VERSION_5;
MQCONNX(chr_l_qmname, &mqcno, &Hcon, &CompCode, &CReason);
if (CompCode == MQCC_FAILED) {
printf("MQCONNX ended with reason code |%ld|\n", CReason);
}
strncpy(od.ObjectName, chr_p_qname, (size_t)MQ_Q_NAME_LENGTH);
if (!strcmp(mode, "I")) {
O_options = MQOO_INQUIRE + MQOO_FAIL_IF_QUIESCING;
} else if (!strcmp(mode, "O")) {
O_options = MQOO_OUTPUT /* open queue for output */
+ MQOO_FAIL_IF_QUIESCING +
MQOO_SET_ALL_CONTEXT; /* but not if MQM stopping */
} else {
printf("Invalid mode %s\n", mode);
APL_GOBACK_FAIL
}
MQOPEN(Hcon, &od, O_options, &Hobj, &OpenCode, &Reason);
if (Reason != MQRC_NONE) {
printf("MQOPEN ended with reason code |%ld|\n", Reason);
}
}
【问题讨论】:
-
澄清一下,您说的是 Oracle 产品,不幸的是,它被命名为 Pro*C/C++,对吧?
-
@JohnBollinger 是的
-
既然您说您提供的相同代码在其他地方也可以使用,我不确定您希望我们在what the manual says 之外告诉您什么。如果您可以提供minimal reproducible example,那么我们可能会做得更多。
-
您应该查看队列管理器的日志以获取更多信息。 MQRC 2018 错误太笼统,无法为您提供真正的帮助。
标签: c ibm-mq mq oracle-pro-c