2016-09-13 11 views
2

私はUFTからMQへのメッセージの読み書きを試みてきました。私はdotnet factoryインスタンスを使用しています。私はキューにアクセスしてメッセージを読み書きする際に問題に直面している間に、私がMQに接続することができるポイントに達しています。UFTからIBM MQへの接続

コードは次のとおりです。

strQMgrName = "queue manager name" 
strMQMDllPath = "C:\\Program Files (x86)\\IBM\WebSphere MQ\\bin\\amqmdnet.dll" 
Set oMqEnvironment = DotNetFactory.CreateInstance("IBM.WMQ.MQEnvironment",strMQMDllPath) 
oMqEnvironment.Hostname = "host name" 
oMqEnvironment.Port = "port number" 
oMqEnvironment.Channel = "channel name" 


Set oMQC = DotNetFactory.CreateInstance("IBM.WMQ.MQC",strMQMDllPath) 
' qmanager name,channel name, connection name 
Set oMqQMgr = DotNetFactory.CreateInstance("IBM.WMQ.MQQueueManager",strMQMDllPath,strQMgrName) 

oMqQMgr.isConnectedが「真

を与える今私は、インスタンスIBM.WMQ.MQQueueManagerの

public MQQueue AccessQueue(string queueName, int openOptions) 

メソッドを使用するワン。誰かが同じことをやってで私を導き、私がメッセージをプッシュすると述べたキュー

からメッセージを読み取ることができる方法を知らせることができますIBMのマニュアルを参照してグーグルと読んだの多くたら

答えて

2

をありがとう、私は置くことができたとMQのメッセージをUFTから取得する。 ..私のために働いたコードスニペットの下に.. ..これがいくつかのものを助けてくれることを願っています。私はPUTとGETを別々に作業していましたので、コードにいくつかの繰り返しがあるかもしれません。

このための前提条件は、IBMのサイトからMQクライアントをダウンロードし、UFTがインストールされているPCにインストールする必要があります.. .. IBM MQクライアントは、フリーウェア

Dim oMQEnvironment 
    Dim oMQM 
    Dim oMQC 
    Dim oMQMessage 
    Dim oMQQueue 
    Dim intOpenOptions 


    strMQMDLLPath = "C:\\Program Files (x86)\\IBM\WebSphere MQ\\bin\\amqmdnet.dll" 
    strHostName= "Host Name" 
    intPort = "Port Number" 
    strChannel ="Channel Name" 
    strMessage ="UFT Test Message" 
    strMQManager = "Quemanager Name" 
    strMessageQueue = "Queue Name" 

ある "コードのこの部分は、露骨ですオンラインの投稿の1つからコピーされます。私はそれが再び

見つけたら、MQ

Dim oMQEnvironment 
Dim oMQM 
Dim oMQC 
Dim oMQMessage 
Dim oMQQueue 

strMQMDLLPath = "C:\\Program Files (x86)\\IBM\WebSphere MQ\\bin\\amqmdnet.dll" 
strHostName= "host name" 
intPort = "port number" 
strChannel ="channel name" 
strMessage ="UFT Test Message" 
strMessageQueue = "message queue intended to access" 
strMQManager = "mq manager name" 
strRemoteMQManager="" 

'Create MQ Instances 
Set oMQC = DotnetFactory.CreateInstance("IBM.WMQ.MQC",strMQMDLLPath) 

'set the properties of the Queue manager 
Set properties = DotNetFactory.CreateInstance("System.Collections.Hashtable") 
       properties.Add oMQC.HOST_NAME_PROPERTY, strHostName 
       properties.Add oMQC.PORT_PROPERTY, intPort 
       properties.Add oMQC.CHANNEL_PROPERTY, strChannel 

'access the queue manager 
Set oMQM = DotnetFactory.CreateInstance("IBM.WMQ.MQQueueManager",strMQMDLLPath,strMQManager,properties) 

'here We are trying to browse the message one by one and keep the messages on the queue. 

'Declare Q open options 
Set oMQQueue = oMQM.AccessQueue(strMessageQueue,oMQC.MQOO_BROWSE) 
Set oMQGetMessageOptions = DotNetFactory.CreateInstance("IBM.WMQ.MQGetMessageOptions",strMQMDLLPath) 
oMQGetMessageOptions.Options = oMQC.MQGMO_BROWSE_FIRST 

Set oMQMessage = DotnetFactory.CreateInstance("IBM.WMQ.MQMessage",strMQMDLLPath) 

    oMQQueue.Get oMQMessage,oMQGetMessageOptions 

Set mqGetNextMsgOpts = DotNetFactory.CreateInstance("IBM.WMQ.MQGetMessageOptions",strMQMDLLPath) 
mqGetNextMsgOpts.Options = oMQC.MQGMO_BROWSE_NEXT 

browseMessages = true 

Do while browseMessages 
     on error resume next 
     messageText = oMQMessage.ReadString(oMQMessage.MessageLength) 
     'Print messageText 
     Set oMQMessage = DotnetFactory.CreateInstance("IBM.WMQ.MQMessage",strMQMDLLPath) 
     oMQQueue.Get oMQMessage,mqGetNextMsgOpts 
     if Err.Number <> 0 then browseMessages =false 
     'Clear both MsgID and CorrelID for next use. 
     oMQMessage.MessageId = oMQC.MQMI_NONE 
     oMQMessage.CorrelationId = oMQC.MQCI_NONE   
Loop 

'Cleanup 
Set oMQQueue = Nothing 
Set oMQMessage= Nothing 
Set oMQOpenOptions= Nothing 
Set oMQM= Nothing 
Set oMQEnvironment = Nothing 
からメッセージを取得するために今すぐ

Set oMQEnvironment = DotNetFactory.CreateInstance("IBM.WMQ.MQEnvironment",strMQMDLLPath) 

    'Initize the Environment 
    With oMQEnvironment 
    .HostName = strHostName 
    .Port = intPort 
    .Channel = strChannel 
    End with 

    On Error Resume Next 
    'Create MQ Instatnces 
    Set oMQM = DotnetFactory.CreateInstance("IBM.WMQ.MQQueueManager",strMQMDLLPath) 

    'Check if MQM Connected 
    If Err.Number <> 0 Then 
     Reporter.ReportEvent micFail , "Step: Creating MQM Object" , "Unable to Connect to MQ Manager at" & strHostName 
     'Exit Test 
    End If 

    Set oMQC = DotnetFactory.CreateInstance("IBM.WMQ.MQC",strMQMDLLPath) 
    Set oMQMessage = DotnetFactory.CreateInstance("IBM.WMQ.MQMessage",strMQMDLLPath) 

    'Declare Q open options 
    intOpenOptions = oMQC.MQOO_OUTPUT or oMQC.MQOO_FAIL_IF_QUIESCING ' 16 + 8192 

    'Open the Q to post the messages 
    If strRemoteMQManager = "" Then 
    Set oMQQueue = oMQM.AccessQueue(strMessageQueue , intOpenOptions) 
    Else 
    Set oMQQueue = oMQM.AccessQueue(strMessageQueue , intOpenOptions ,strRemoteMQManager, "","") 
    End If 

    'Format Message 
    With oMQMessage 
    .CharacterSet = 819 
    .WriteString(strMessage) 
    End with 

    'Post Message 
    With oMQQueue 
    .Put(oMQMessage) 
    .Close() 
    End With 
クライアントモードでキュー・マネージャーに接続するためのアプリケーションのための」(UFT)のリンクを掲載します
関連する問題