delphi客户端连接IBM MQ

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了delphi客户端连接IBM MQ相关的知识,希望对你有一定的参考价值。

项目需要:his-lis之前交互以表/视图BS方式完成交互,现需要更换成用IBM MQ消息平台的方式完成交互。

修改后的交互:

技术分享图片

部署测试环境:

    Windows2003+Windows xp+IBM MQ 7.0.5


具体实现步骤:

  1. 部署MQ客户端,delphi连接IBM MQ需要MQ客户端支持;

  2. 部署MQ服务端;

    技术分享图片

    技术分享图片

    技术分享图片

    技术分享图片

    技术分享图片

    技术分享图片



  3. delphi客户端编写;

    窗体源码:

  4. object Form1: TForm1
      Left = 744
      Top = 189
      BorderIcons = [biSystemMenu, biMinimize]
      BorderStyle = bsSingle
      Caption = #26041#27491'HIS_IBM MQ'#28040#24687#23458#25143#31471#27979#35797#24037#20855'_By '#35199#21335#21306' '#23002#28023#26093
      ClientHeight = 480
      ClientWidth = 826
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      Icon.Data = {
        0000010001002020000001002000A81000001600000028000000200000004000
        0000010020000000000000100000120B0000120B000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000003535FF000000FF000303FF960202
        FF7F0000FF000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000007272FF000000FF000404FF860505
        FF770000FF000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000000
        000000000000000000000000000000000000000000000000FF000303FF790202
        FF710000FF000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000000
        000000000000000000000000000000000000000000000000FF000202FF6F0202
        FF6D0000FF000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000000
        000000000000000000000000000000000000FEFEFF000000FF000202FF6B0101
        FF6B0000FF00FEFEFF0000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000000
        000000000000000000000000000000000000A2A2FF000000FF000505FF100808
        FF110808FF081A1AFF020303FF001F1FFF00000000000101FF000202FF680101
        FF690101FF00000000001F1FFF000303FF001A1AFF020808FF080808FF110505
        FF100000FF00A2A2FF0000000000000000000000000000000000000000000000
        000000000000000000000000000000000000A4A4FF000000FF000202FF6C0101
        FFCF0101FFBD0303FFA10303FF7A0202FF650303FF4E0202FF3A0101FF8C0202
        FF8F0303FF3A0303FF4E0202FF650303FF7A0303FFA10101FFBD0101FFCF0202
        FF6C0000FF00A4A4FF0000000000000000000000000000000000000000000000
        000000000000000000000000000000000000000000000202FF000404FF460000
        FFF40000FFFF0000FFFF0000FFFF0000FFFF0000FFFA0000FFF50000FFF90000
        FFFA0000FFF50000FFFA0000FFFF0000FFFF0000FFFF0000FFFF0000FFF40404
        FF460202FF000000000000000000000000000000000000000000000000000000
        000000000000000000000000000000000000000000000303FF000404FF210101
        FFE10000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0101FFE10404
        FF210303FF000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000303FF000505FF0B0101FF800000
        FFF90000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFF90101
        FF800505FF0B0303FF0000000000000000000000000000000000000000000000
        00000000000000000000000000000202FF000303FF150101FF980000FFF90000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFF90101FF980303FF150202FF00000000000000000000000000000000000000
        0000000000002020FF000000FF000404FF250101FFB00000FFFD0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFD0101FFB00404FF250000FF002020FF0000000000000000000000
        00000C0CFF000000FF000303FF390101FFCA0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0101FFCA0303FF390000FF000C0CFF00000000000606
        FF000B0BFF020303FF500101FFDC0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0101FFDC0303FF500B0BFF020606FF000909
        FF070202FF690000FFEB0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFEB0202FF690909FF070202
        FF860000FFF30000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFF30202FF860303
        FF3D0101FF9C0000FFF80000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFF80101FF9C0303FF3D0505
        FF000606FF1F0101FFDF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0101FFDF0606FF1F0505FF000303
        FF000404FF430000FFF30000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFF30404FF430303FF000000
        FF000202FF790000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFD0101FFDC0000FFF20000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFF20101FFDC0000FFFD0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0202FF790000FF001111
        FF070202FFAD0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0101FFBA0505FF280101FFAE0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0101FFAE0505FF280101FFBA0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0202FFAD1111FF070505
        FF280101FFE00000FFFF0101FFF20101FFCF0000FFD10000FFFD0000FFFF0101
        FFCF0202FF2A0909FF0C0101FFC30000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0101FFC30909FF0C0202FF2A0101FFCF0000
        FFFF0000FFFD0000FFD10101FFCF0101FFF20000FFFF0101FFE00505FF280606
        FF320303FF870303FF5F0404FF3A0A0AFF130404FF2E0101FFE30000FFDE0303
        FF3E0000FF000505FF220101FFE20000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0101FFE20505FF220000FF000303FF3E0000
        FFDE0101FFE30404FF2E0A0AFF130404FF3A0303FF5F0303FF870606FF321212
        FF021515FF021313FF00000000000808FF000707FF080202FF9E0303FF540000
        FF000303FF000404FF3A0000FFF20000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFF20404FF3A0303FF000000FF000303
        FF540202FF9E0707FF080808FF00000000001313FF001515FF021212FF020000
        00000000000000000000000000002C2CFF001313FF010606FF1A0404FF050505
        FF000000FF000505FF5E0000FFFD0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFD0505FF5E0000FF000505FF000404
        FF050606FF1A1313FF012C2CFF00000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000003B3B
        FF000000FF000202FF8F0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0202FF8F0000FF003B3BFF000000
        0000000000000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000909
        FF000C0CFF050101FFAF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFF0000FFFF0000FFFF0101FFAF0C0CFF050909FF000000
        0000000000000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000707
        FF000707FF110101FFCC0000FFFF0000FFF80000FFFE0000FFFF0000FFFF0000
        FFFF0000FFFF0000FFFE0000FFF80000FFFF0101FFCC0707FF110707FF000000
        0000000000000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000303
        FF000404FF310101FFCE0202FF830303FF480101FFC70000FFFF0000FFFF0000
        FFFF0000FFFF0101FFC70303FF480202FF830101FFCE0404FF310303FF000000
        0000000000000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000303
        FF000505FF180404FF290B0BFF020000FF000303FF5A0000FFF80000FFFF0000
        FFFF0000FFF80303FF5A0000FF000B0BFF020404FF290505FF180303FF000000
        0000000000000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000000
        FF000000FF000000FF000000FF000606FF000707FF100101FFBB0000FFFF0000
        FFFF0101FFBB0707FF100606FF000000FF000000FF000000FF000000FF000000
        0000000000000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000C0C0FF000000FF000303FF550000FFF70000
        FFF60303FF550000FF00C6C6FF00000000000000000000000000000000000000
        000000000000000000000000000000000000000000000000000000000000FFFE
        7FFFFFFE7FFFFFFE7FFFFFFE7FFFFFFE7FFFFE1E787FFE00007FFE00007FFE00
        007FFC00003FF800001FF000000FE00000078000000100000000000000000000
        000080000001800000018000000100000000000000000040020038C0031CF8C0
        031FFFC003FFFF8001FFFF8001FFFF8001FFFF8811FFFFB81DFFFFFC3FFF}
      OldCreateOrder = False
      Position = poDesktopCenter
      PixelsPerInch = 96
      TextHeight = 13
      object Label1: TLabel
        Left = 8
        Top = 8
        Width = 80
        Height = 19
        Caption = #26381#21153#22120'IP'
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label2: TLabel
        Left = 286
        Top = 8
        Width = 100
        Height = 19
        Caption = #38431#21015#31649#29702#22120
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label3: TLabel
        Left = 8
        Top = 38
        Width = 80
        Height = 19
        Caption = #26381#21153#31471#21475
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label4: TLabel
        Left = 286
        Top = 41
        Width = 80
        Height = 19
        Caption = #38431#21015#21517#31216
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label5: TLabel
        Left = 567
        Top = 8
        Width = 80
        Height = 19
        Caption = #36890#36947#21517#31216
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label6: TLabel
        Left = 32
        Top = 98
        Width = 80
        Height = 19
        Caption = #23646#24615#21517#31216
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label7: TLabel
        Left = 567
        Top = 41
        Width = 80
        Height = 19
        Caption = #29992#25143#26631#24535
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label8: TLabel
        Left = 172
        Top = 98
        Width = 60
        Height = 19
        Caption = #23646#24615#20540
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label9: TLabel
        Left = 8
        Top = 378
        Width = 160
        Height = 19
        Caption = 'replyToQueueName'
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label10: TLabel
        Left = 8
        Top = 346
        Width = 130
        Height = 19
        Caption = 'extend_sub_id'
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label11: TLabel
        Left = 8
        Top = 314
        Width = 130
        Height = 19
        Caption = 'order_exec_id'
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label12: TLabel
        Left = 8
        Top = 282
        Width = 110
        Height = 19
        Caption = 'send_sys_id'
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label13: TLabel
        Left = 8
        Top = 250
        Width = 120
        Height = 19
        Caption = 'exec_unit_id'
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label14: TLabel
        Left = 8
        Top = 218
        Width = 130
        Height = 19
        Caption = 'apply_unit_id'
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label15: TLabel
        Left = 8
        Top = 186
        Width = 90
        Height = 19
        Caption = 'domain_id'
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label16: TLabel
        Left = 8
        Top = 154
        Width = 100
        Height = 19
        Caption = 'service_id'
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label17: TLabel
        Left = 8
        Top = 122
        Width = 110
        Height = 19
        Caption = 'hospital_id'
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Label18: TLabel
        Left = 8
        Top = 72
        Width = 80
        Height = 19
        Caption = #23383#31526#32534#30721
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
      end
      object Memo1: TMemo
        Left = 303
        Top = 308
        Width = 521
        Height = 166
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
        ScrollBars = ssBoth
        TabOrder = 0
      end
      object Edit1: TEdit
        Left = 90
        Top = 4
        Width = 161
        Height = 27
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
        TabOrder = 1
        Text = '192.168.188.130'
      end
      object Edit2: TEdit
        Left = 90
        Top = 36
        Width = 161
        Height = 27
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
        TabOrder = 2
        Text = '1414'
      end
      object Edit3: TEdit
        Left = 384
        Top = 4
        Width = 161
        Height = 27
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
        TabOrder = 3
        Text = 'QueueManger'
      end
      object Edit4: TEdit
        Left = 384
        Top = 36
        Width = 161
        Height = 27
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
        TabOrder = 4
        Text = 'LocalQueue'
      end
      object Edit5: TEdit
        Left = 649
        Top = 4
        Width = 161
        Height = 27
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
        TabOrder = 5
        Text = 'CONN'
      end
      object Edit6: TEdit
        Left = 649
        Top = 36
        Width = 161
        Height = 27
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
        TabOrder = 6
        Text = 'hji116'
      end
      object Edit7: TEdit
        Left = 157
        Top = 122
        Width = 140
        Height = 21
        TabOrder = 7
        Text = '450960682'
      end
      object Edit8: TEdit
        Left = 157
        Top = 154
        Width = 140
        Height = 21
        TabOrder = 8
        Text = 'BS004'
      end
      object Edit9: TEdit
        Left = 157
        Top = 186
        Width = 140
        Height = 21
        TabOrder = 9
        Text = '0'
      end
      object Edit10: TEdit
        Left = 156
        Top = 218
        Width = 140
        Height = 21
        TabOrder = 10
        Text = '0'
      end
      object Edit11: TEdit
        Left = 8
        Top = 402
        Width = 287
        Height = 21
        TabOrder = 11
      end
      object Edit13: TEdit
        Left = 156
        Top = 346
        Width = 140
        Height = 21
        TabOrder = 12
        Text = '0'
      end
      object Edit14: TEdit
        Left = 156
        Top = 314
        Width = 140
        Height = 21
        TabOrder = 13
        Text = '0'
      end
      object Edit15: TEdit
        Left = 156
        Top = 282
        Width = 140
        Height = 21
        TabOrder = 14
        Text = 'S005'
      end
      object Edit16: TEdit
        Left = 156
        Top = 250
        Width = 140
        Height = 21
        TabOrder = 15
        Text = '0'
      end
      object Button1: TButton
        Left = 8
        Top = 424
        Width = 105
        Height = 49
        Caption = #21457#36865#28040#24687
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -21
        Font.Name = #26032#23435#20307
        Font.Style = [fsBold]
        ParentFont = False
        TabOrder = 16
        OnClick = Button1Click
      end
      object Button2: TButton
        Left = 187
        Top = 424
        Width = 105
        Height = 49
        Caption = #25509#25910#28040#24687
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -21
        Font.Name = #26032#23435#20307
        Font.Style = [fsBold]
        ParentFont = False
        TabOrder = 17
        OnClick = Button2Click
      end
      object Memo2: TMemo
        Left = 303
        Top = 80
        Width = 521
        Height = 113
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
        ScrollBars = ssBoth
        TabOrder = 18
      end
      object Edit12: TEdit
        Left = 90
        Top = 67
        Width = 161
        Height = 27
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
        TabOrder = 19
        Text = '1381'
      end
      object Memo3: TMemo
        Left = 303
        Top = 195
        Width = 521
        Height = 113
        Font.Charset = GB2312_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #26032#23435#20307
        Font.Style = []
        ParentFont = False
        ScrollBars = ssBoth
        TabOrder = 20
      end
    end

   程序源码:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,MQIC,CMQXPas,untPub;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Memo1: TMemo;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit10: TEdit;
    Edit11: TEdit;
    Edit13: TEdit;
    Edit14: TEdit;
    Edit15: TEdit;
    Edit16: TEdit;
    Button1: TButton;
    Button2: TButton;
    Memo2: TMemo;
    Label18: TLabel;
    Edit12: TEdit;
    Memo3: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  pom: TMQCD;
  ConnectOpts: MQCNO;
  QMgrPutName: MQCHAR48; //发送队列管理器名称
  MyHConn: MQHCONN;
  Compcode, Reason: MQLONG;
  ObjDesc: MQOD;
  ConnOpts: MQLONG;
  AHObj: MQHOBJ;
  sErrMsgTemp: string;
  sXML:string;
  pBuffer: PChar;
  MsgDesc: MQMD;
  PutMsgOptions: MQPMO;
begin
  //1连接队列
  StrCopy(QMgrPutName, PChar(Edit3.Text));

  MyHConn := 0;
  SetMQCD_CLIENT_CONN_DEFAULT(pom);

  StrCopy(pom.ConnectionName,PChar(trim(Edit1.Text )+'('+trim(edit2.text)+')'));
  StrCopy(pom.ChannelName,PChar(trim(edit5.text)));
  StrCopy(pom.QMgrName,PChar(trim(edit4.text)));
  StrCopy(pom.UserIdentifier,PChar(trim(edit6.text)));
  pom.Version := MQCD_VERSION_7;

  ConnectOpts := MQCNO_DEFAULT;
  ConnectOpts.ClientConnOffset := 0;
  ConnectOpts.ClientConnPtr := @pom;
  ConnectOpts.Version := MQCNO_VERSION_2;
  MQCONNX(@QMgrPutName, @ConnectOpts, @MyHConn, @Compcode, @Reason);
  if Compcode = MQCC_OK then
    //showmessage('连接队列_成功')
    memo1.Lines.Add(FormatdateTime('yyyy-MM-dd HH:mm:ss',now)+'连接队列_成功...')
  else
    //showmessage('连接队列_失败|' + inttostr(Compcode) + '|' + inttostr(Reason));
    memo1.Lines.Add(FormatdateTime('yyyy-MM-dd HH:mm:ss',now)+'连接队列_失败|' + inttostr(Compcode) + '|' + inttostr(Reason));

  //2.打开队列
  ObjDesc := MQOD_DEFAULT;
  StrCopy(ObjDesc.ObjectName,PChar(trim(edit4.text)));
  ConnOpts := MQOO_OUTPUT + MQOO_FAIL_IF_QUIESCING;
  MQOPEN(MyHConn, @ObjDesc, ConnOpts, @AHObj, @CompCode, @Reason);
  if (Compcode = MQCC_OK) and (Reason = MQRC_NONE) then
  begin
    //ShowMessage('打开队列_成功|');
    memo1.Lines.Add(FormatdateTime('yyyy-MM-dd HH:mm:ss',now)+'打开队列_成功|');
  end
  else
  begin
    //ShowMessage('打开队列_失败|' + '|' + inttostr(Compcode) + '|' + inttostr(Reason));
    memo1.Lines.Add(FormatdateTime('yyyy-MM-dd HH:mm:ss',now)+'打开队列_失败|' + '|' + inttostr(Compcode) + '|' + inttostr(Reason));
  end;

  //3.发送消息
  if AHObj <= 0 then Exit;
  sXML:=memo2.Text ;
  pBuffer:=StrAlloc(Length(sXML));
  pBuffer := StrPCopy(pBuffer, sXML);
  MsgDesc := MQMD_DEFAULT;
  MsgDesc.Version := MQMD_VERSION_2;
  MsgDesc.Format := MQFMT_STRING;
  MsgDesc.CodedCharSetId := strtoint(trim(edit12.text));    //MQCCSI_APPL; 字符编码
  PutMsgOptions := MQPMO_DEFAULT;
  PutMsgOptions.Version := MQPMO_VERSION_2;
  PutMsgOptions.Options := MQPMO_FAIL_IF_QUIESCING;
  MQPUT(MyHConn, AHObj, @MsgDesc, @PutMsgOptions, Length(sXML), pBuffer, @CompCode, @Reason);
  if (Reason <> MQRC_NONE) or (CompCode <> MQCC_OK) then
  begin
    //ShowMessage('往消息队列发送消息失败|' + inttostr(CompCode) + '|' + inttostr(Reason)+#13#10+sXML);
    memo1.Lines.Add(FormatdateTime('yyyy-MM-dd HH:mm:ss',now)+'往消息队列发送消息失败|' + inttostr(CompCode) + '|' + inttostr(Reason)+#13#10+'消息内容:'+sXML);
  end
  else begin
    //ShowMessage('往消息队列发送消息成功!'+#13#10+sXML);
     memo1.Lines.Add(FormatdateTime('yyyy-MM-dd HH:mm:ss',now)+'往消息队列发送消息成功!'+#13#10+'消息内容:'+sXML);
  end;

  //4.关闭队列
  ConnOpts := MQCO_NONE;
  MQCLOSE(MyHConn, @AHObj, ConnOpts, @CompCode, @Reason);
  if (Compcode = MQCC_OK) and (Reason = MQRC_NONE) then
  begin
    //ShowMessage('关闭队列成功');
    memo1.Lines.Add(FormatdateTime('yyyy-MM-dd HH:mm:ss',now)+'关闭队列成功');
  end
  else
  begin
    memo1.Lines.Add(FormatdateTime('yyyy-MM-dd HH:mm:ss',now)+'关闭队列失败|' + inttostr(Compcode) + '|' + inttostr(Reason));
  end;

  //5.关闭连接
  MQDISC(@MyHConn, @CompCode, @Reason);
  if (CompCode = MQCC_OK) and (Reason = MQRC_NONE) then
  begin
    //ShowMessage('连接断开成功');
    memo1.Lines.Add(FormatdateTime('yyyy-MM-dd HH:mm:ss',now)+'连接断开成功');
  end
  else
  begin
    //ShowMessage('连接断开错误|' + inttostr(CompCode) + '|' + inttostr(Reason));
    memo1.Lines.Add(FormatdateTime('yyyy-MM-dd HH:mm:ss',now)+'连接断开错误|' + inttostr(CompCode) + '|' + inttostr(Reason));
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  conn: Tconn;
  MyHConn: MQHCONN;
  AHObj:MQHOBJ;
  msg:string;
  outXML:string;
  sError :string;
  length:integer;
begin
  length:=0;
  conn.ConnectionName:=trim(Edit1.Text )+'('+trim(edit2.text)+')';
  conn.ChannelName:=trim(edit5.text);
  conn.QMgrName:=trim(edit3.text);
  conn.QueueName :=trim(edit4.text);
  MyHConn:=0;
  while true do
  begin
    if not perpareMQGET(conn,MyHConn,AHObj,msg) then break;
    try
      if MQ_GET(MyHConn,AHObj,0,outXML,msg) then
      begin
        //memo3.Lines.Clear;
        memo3.Lines.Add(outXML) ;
        length:=length+1;
      end
      else
      begin
        memo3.Lines.Add('当前队列中无消息。。。'+msg);
        memo3.Lines.Add('当前队列深度为:'+inttostr(length)) ;
        break;
      end;
    finally
      if not endMQGET(MyHConn,AHObj,msg) then
        ShowMessage(msg);
    end;
  end;

end;
end.

{
 用ReplyToQ 存贮消息头信息的方式如下:
StrCopy(MsgDesc.ReplyToQ, PChar(sHeader));
sHeader 存储消息头内容,格式为
hospital_id:service_id:domain_id:apply_unit_id:exec_unit_id:send_sys_id:order_exec_id:extend_sub_id
中间由冒号分隔
各单元注释
hospital_id: 医疗机构代码
service_id: 消息ID
domain_id: 就诊类别ID(01 门诊,2 急诊,0201 普通急诊,0202 急诊留观,03 住院,04 体检,0401 普通体检,0402
干保体检,05 转院)
apply_unit_id: 申请科室ID
exec_unit_id: 执行科室ID
send_sys_id: 发送系统ID
order_exec_id:医嘱执行分类编码
extend_sub_id:扩展码(empi使用时放入域ID,其它系统标0)
}

效果截图:

技术分享图片

技术分享图片

技术分享图片

技术分享图片

技术分享图片

技术分享图片


下载链接:delphi客户端连接IBM MQ

以上是关于delphi客户端连接IBM MQ的主要内容,如果未能解决你的问题,请参考以下文章

IBM MQ学习过程问题汇总

如何测试客户端跟WebSphere MQ队列管理器的连接

将 ibm cloud app-connect 与 mq 连接的最佳方式是啥?

连接IBM MQ原因码报2035的错误解决办法

Java连接MQ的实例, 测试类

用于传输大量文件的 IBM MQ 调优