Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

WebSphere

Title: WebSphere Question: Using IBM Message Queuing WebSphere with Delphi. Answer: I will not explain how to use WebSphere function's since they are very good explained in IBM documentation I will focus on only one function MQCONNX since you can use it to connect to WebSphere without using eviroment variables in Windows. First, you need to download WebSphere MQ - MQI for Delphi from http://www-1.ibm.com/support/docview.wss?rs=171&uid=swg24007060&loc=en_US&cs=utf-8?=en I recommend you to use MQIC unit. Then download http://www.torry.net/samples/samples/other/cmqpas.zip - from here copy TMQCD record definition and SetMQCD_CLIENT_CONN_DEFAULT procedure. And here is procedure: procedure TForm1.Button1Click(Sender: TObject); var pom: TMQCD; ConnectOpts : MQCNO; CompCode, Reason : MQLONG; QMgrName : MQCHAR48; Hconn : MQHCONN; begin QMgrName := 'QM_OTHER'; SetMQCD_CLIENT_CONN_DEFAULT(pom); pom.ConnectionName := '122.118.1.111(1415)'; pom.QMgrName := 'QM_OTHER'; pom.ChannelName := 'CLIENT.QM_OTHER'; ConnectOpts := MQCNO_DEFAULT; ConnectOpts.ClientConnPtr := @pom; ConnectOpts.Version := MQCNO_VERSION_2; MQCONNX ( @QMgrName, @ConnectOpts, @HConn, @Compcode, @Reason); if CompCode MQCC_OK then ShowMessage( 'Connect Failed' ); end If you want to put flag Confirmation of Delivery (COD) on message or Confirmation of Arrival (COA) You can do it something like this: var MsgDesc : MQMD; PutMsgOptions : MQPMO; BufferLength : MQLONG; CompCode : MQLONG; Buffer : array [0..MAX_SIZE] of Char; Hconn : MQHCONN; ObjDesc : MQOD; begin FillChar(buffer,SizeOf(Buffer),0); BufferLength := Length('Message'); StrPCopy(buffer,'Message'); MsgDesc := MQMD_DEFAULT; MsgDesc.Report := MQRO_COA_WITH_DATA + MQRO_COD_WITH_DATA; MsgDesc.PutApplType := MQAT_WINDOWS; MsgDesc.FeedBack := MQFB_COA + MQFB_COD; StrPCopy(MsgDesc.ReplyToQMgr,'QM_REPLY'); StrPCopy(MsgDesc.ReplyToQ, 'queue'); PutMsgOptions := MQPMO_DEFAULT; MQPUT1 (Hconn, @ObjDesc, @MsgDesc, @PutMsgOptions, BufferLength, @Buffer, @Compcode, @intReason ); end Here is an example of opening queue to put messages: Options := MQOO_FAIL_IF_QUIESCING + MQOO_OUTPUT; ObjDesc := MQOD_DEFAULT; with ObjDesc do begin ObjectName := ''; for i := 1 to Length(edtObjName.Text) do ObjectName[i-1] := edtObjName.Text[i]; ObjectName := ObjectName; end; MQOPEN (Hconn, @ObjDesc, Options, @HObj, @Compcode, @Reason ); if CompCode MQCC_OK then ShowMessage( 'Open Failed' ); And here is example of opening object to put messages: var Options,CompCode, Reason : MQLONG; i: Integer; begin Options := MQOO_FAIL_IF_QUIESCING + MQOO_INPUT_AS_Q_DEF; ObjDesc := MQOD_DEFAULT; with ObjDesc do begin ObjectName := ''; for i := 1 to Length(edtObjName.Text) do ObjectName[i-1] := edtObjName.Text[i]; ObjectName := ObjectName; end; MQOPEN (Hconn, @ObjDesc, Options, @HObj, @Compcode, @Reason ); if CompCode MQCC_OK then ShowMessage( 'Open Failed' ); Open button in my Attachement URL is made just for puting messages, if you want to get message you need to change Open, as I described.