ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » General IBM MQ Support » VB.Net sample...

Post new topic  Reply to topic
 VB.Net sample... « View previous topic :: View next topic » 
Author Message
jjm335
PostPosted: Thu Oct 26, 2006 10:56 am    Post subject: VB.Net sample... Reply with quote

Newbie

Joined: 29 Sep 2006
Posts: 4

Does anyone have a sample of an MQ Put and Get using the CorrelationId for the Get? I should be able to get this but I must be missing something simple.

A sample would be so much help!

Code:

Dim mqQMgr As MQQueueManager 
Dim mqSendQueue As MQQueue   
Dim mqReceiveQueue As MQQueue
Dim mqMsg As MQMessage       
Dim mqPutMsgOpts As MQPutMessageOptions 
Dim mqGetMsgOpts As MQGetMessageOptions 
Dim isContinue As Boolean = True         
'
'Attempt to Connect to the MQ Queue Manager
'
Try
    mqQMgr = New MQQueueManager(gMQMgrName, gMQMgrName, gMQConName & "(" & gMQPortNum & ")")
Catch mqe As IBM.WMQ.MQException
    isContinue = False
End Try

If (isContinue) Then
    '
    'Try to open the Send Queue to perform the Put
    '
    Try
        mqSendQueue = mqQMgr.AccessQueue(gSendQueue, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING)
    Catch mqe As IBM.WMQ.MQException
        isContinue = False
    End Try
End If

If (isContinue = True) Then
    mqMsg = New MQMessage

    mqMsg.Format = MQC.MQFMT_STRING
    mqMsg.Encoding = MQC.MQENC_NATIVE
    mqMsg.CharacterSet = 819
    mqMsg.Expiry = 1000
    mqMsg.MessageType = MQC.MQMT_REQUEST
    mqMsg.Persistence = False
    mqMsg.ReplyToQueueManagerName = gMQMgrName.ToString
    mqMsg.ReplyToQueueName = gReceiveQueue.ToString
    '
    'Set the Correlation Id to the Message Id ???
    '
    'mqMsg.CorrelationId = mqMsg.MessageId

    mqMsg.WriteString(mStrMsg)

    mqPutMsgOpts = New MQPutMessageOptions
    '
    'Try to Put the message on the Send Queue
    '
    Try
        mqSendQueue.Put(mqMsg, mqPutMsgOpts)
    Catch mqe As IBM.WMQ.MQException
        isContinue = False
    End Try
End If

If (isContinue) Then
    '
    'Try to open the Receive Queue to perform the Get
    '
    Try
        mqReceiveQueue = mqQMgr.AccessQueue(gReceiveQueue, MQC.MQMO_MATCH_CORREL_ID Or MQC.MQOO_OUTPUT Or MQC.MQOO_INPUT_SHARED Or MQC.MQOO_INQUIRE)
    Catch mqe As IBM.WMQ.MQException
        isContinue = False
    End Try
End If

If (isContinue = True) Then
    mqGetMsgOpts = New MQGetMessageOptions
    mqGetMsgOpts.WaitInterval = 30000
    '
    'Match the Correlation Id
    '
    mqGetMsgOpts.MatchOptions = MQC.MQMO_MATCH_CORREL_ID
    mqGetMsgOpts.Options = MQC.MQGMO_NO_SYNCPOINT + MQC.MQGMO_CONVERT + MQC.MQGMO_WAIT + MQC.MQGMO_FAIL_IF_QUIESCING
    '
    'Try to Get the message on the Receive Queue
    '
    Try
        mqReceiveQueue.Get(mqMsg, mqGetMsgOpts)

        If (mqMsg.Format.CompareTo(MQC.MQFMT_STRING) = 0) Then
      Dim mResults As String = mqMsg.ReadString(mqMsg.MessageLength).ToString
      SetResults(mCode.Success, "Successful", mResults)
        Else
      isContinue = False
        End If
    Catch mqe As IBM.WMQ.MQException
        isContinue = False
    End Try
End If

Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Oct 26, 2006 10:58 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You probably need to clear the MsgId before you do the Get.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
jjm335
PostPosted: Thu Oct 26, 2006 11:06 am    Post subject: Reply with quote

Newbie

Joined: 29 Sep 2006
Posts: 4

How do I set the Message Id to nothing?

Do I use the Clear?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Oct 26, 2006 11:22 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Might be better to create a whole new MqMsg.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
jjm335
PostPosted: Thu Oct 26, 2006 11:46 am    Post subject: Reply with quote

Newbie

Joined: 29 Sep 2006
Posts: 4

IT WORKS!

Thanks so much, I thought it was probably something simple.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General IBM MQ Support » VB.Net sample...
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.