加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Delphi WebSphere MQ远程连接

发布时间:2020-12-15 09:25:37 所属栏目:大数据 来源:网络整理
导读:我正在Delphi中编写一个应用程序来连接到远程MQ服务器并获取消息. 我在我的comp上安装了一个MQ Server并编写了一个测试应用程序. 所有井连接,打开,放置,获取,…一切正常. 然后我尝试通过更改地址连接到远程MQ,它工作但不正确,它仍然适用于本地MQ仍然从本地获
我正在Delphi中编写一个应用程序来连接到远程MQ服务器并获取消息.
我在我的comp上安装了一个MQ Server并编写了一个测试应用程序.
所有井连接,打开,放置,获取,…一切正常.
然后我尝试通过更改地址连接到远程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是绑定模式(共享内存)连接,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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读