I am writing an application in Delphi to connect to remote MQ Server and get messages.
I installed a MQ Server on my comp and wrote a test application.
All well Connect,Open,Put,Get,.. all works well.
Then I tried to connect to remote MQ by changing address, it works but not correctly, it works with local MQ still and get info from local. not switched to other remote server!!!!
My source is as bellow, What I should do? Thanks
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]));
The code snippet doesn’t show the
usesstatement. According to the MA7Q docs,The
MQIis the bindings mode (shared memory) connection and theMQICis the client connection over the network stack.It is possible to have both available and let the application determine which to use at run-time. According to the WMQ Infocenter:
This suggests to me that you have both libraries in the path and the connection is finding the local QMgr first and ignoring the client connection parameters, or perhaps that you are using the MQI library where you want the MQIC library. Make sure the MQIC library is in the path and change your
usesstatement.If switching the library does not alone solve the problem, consider specifying
MQCNO_CLIENT_BINDINGinstead ofMQCNO_STANDARD_BINDING.