gpt4 book ai didi

Delphi WebSphere MQ 远程连接

转载 作者:行者123 更新时间:2023-12-03 15:25:27 24 4
gpt4 key购买 nike

我正在 Delphi 中编写一个应用程序来连接到远程 MQ 服务器并获取消息。
我在我的电脑上安装了 MQ 服务器并编写了一个测试应用程序。
一切正常 连接、打开、放置、获取...一切正常。
然后我尝试通过更改地址连接到远程 MQ,它可以工作但不正确,它仍然可以与本地 MQ 一起使用并从本地获取信息。没有切换到其他远程服务器!!!
我的来源如下,我应该做什么?谢谢

var
QMgrName : MQCHAR48;
ConnectOpts : TMQCNO;
ClientConn : TMQCD;
Compcode : MQLONG;
Reason : MQLONG;
begin
StrPCopy(QMgrName, AQueueManager+#0);
ConnectOpts.StrucId := MQCNO_STRUC_ID;
ConnectOpts.Version := MQCNO_VERSION_1;
ConnectOpts.Options := MQCNO_STANDARD_BINDING;
ConnectOpts.ClientConnOffset := 0;
ConnectOpts.ClientConnPtr := @ClientConn;

with ClientConn do begin
StrPCopy(ClientConn.ConnectionName, format('%s(%s)'#0, [AIP,APort]));
Version := MQCD_VERSION_6;
ChannelType := MQCHT_CLNTCONN;
TransportType := MQXPT_TCP;
Desc := '';
QMgrName := '';
XmitQName := '';
ShortConnectionName := '';
MCAName := '';
ModeName := '';
TpName := '';
BatchSize := 50;
DiscInterval := 6000;
ShortRetryCount := 10;
ShortRetryInterval := 60;
LongRetryCount := 999999999;
LongRetryInterval := 1200;
SecurityExit := '';
MsgExit := '';
SendExit := '';
ReceiveExit := '';
SeqNumberWrap := 999999999;
MaxMsgLength := 4194304;
PutAuthority := MQPA_DEFAULT;
DataConversion := MQCDC_NO_SENDER_CONVERSION;
SecurityUserData := '';
MsgUserData := '';
SendUserData := '';
ReceiveUserData := '';
UserIdentifier := '';
Password := '';
MCAUserIdentifier := '';
MCAType := MQMCAT_PROCESS;
ConnectionName := '';
RemoteUserIdentifier := '';
RemotePassword := '';
MsgRetryExit := '';
MsgRetryUserData := '';
MsgRetryCount := 10;
MsgRetryInterval := 1000;
HeartbeatInterval := 1;
BatchInterval := 0;
NonPersistentMsgSpeed := MQNPMS_FAST;
StrucLength := MQCD_LENGTH_6;
ExitNameLength := MQ_EXIT_NAME_LENGTH;
ExitDataLength := MQ_EXIT_DATA_LENGTH;
MsgExitsDefined := 0;
SendExitsDefined := 0;
ReceiveExitsDefined := 0;
MsgExitPtr := nil;
MsgUserDataPtr := nil;
SendExitPtr := nil;
SendUserDataPtr := nil;
ReceiveExitPtr := nil;
ReceiveUserDataPtr := nil;
ClusterPtr := nil;
ClustersDefined := 0;
NetworkPriority := 0;
LongMCAUserIdLength := 0;
LongRemoteUserIdLength := 0;
LongMCAUserIdPtr := nil;
LongRemoteUserIdPtr := nil;
// MCASecurityId := MQSID_NONE_ARRAY;
// RemoteSecurityId := MQSID_NONE_ARRAY;
end;
MQCONNX(@QMgrName, ConnectOpts, HConn,Compcode,Reason);
if CompCode <> MQCC_OK then
raise Exception.Create(format('MQCONNX Fail, Completion Code: %d, Reason: %d',[CompCode,Reason]));

最佳答案

代码片段不显示uses语句。根据the MA7Q docs ,

The SupportPac contains two files called 'MQI.PAS' and 'MQIC.PAS'. These are Pascal sources that should be placed somewhere in the Search Path of Delphi to be included in your Pascal program. The way to include it is like using any unit in Pascal:

uses MQI;
or
uses MQIC;

MQI 是绑定(bind)模式(共享内存)连接,MQIC 是通过网络堆栈的客户端连接。

可以同时使用两者并让应用程序在运行时决定使用哪一个。根据WMQ Infocenter :

If you are linking to the mqm library, then a standard server connection using the default bind type is attempted first. If the underlying server library failed to load, a client connection is attempted instead.

这表明您在路径中拥有两个库,并且连接首先查找本地 QMgr 并忽略客户端连接参数,或者您可能在需要 MQIC 库的地方使用 MQI 库。确保 MQIC 库位于路径中并更改您的 uses 语句。

如果单独切换库无法解决问题,请考虑指定 MQCNO_CLIENT_BINDING 而不是 MQCNO_STANDARD_BINDING

关于Delphi WebSphere MQ 远程连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14457693/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com