|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
VB.net MQGET n MQPUT |
« View previous topic :: View next topic » |
Author |
Message
|
vandemon |
Posted: Wed Jul 07, 2010 8:48 pm Post subject: VB.net MQGET n MQPUT |
|
|
Apprentice
Joined: 14 Jun 2010 Posts: 32
|
Following is my code :
Code: |
Imports MQ
'Imports System.Threading.Thread
Public Class frmHost
Dim mqQMgr As MQQueueManager
Dim mqQueue1 As MQQueue
Dim mqQueue2 As MQQueue
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
If (txtRequestQ.Text Is Nothing Or txtRequestQ.Text Is Nothing) Then
MsgBox("Please key in the request queue and response queue")
Else
Try
If (mqQMgr Is Nothing) Then
mqQMgr = New MQQueueManager("")
End If
Try
mqQueue1 = mqQMgr.AccessQueue(txtRequestQ.Text, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING)
Try
mqQueue2 = mqQMgr.AccessQueue(txtResponseQ.Text, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING)
btnStop.Enabled = True
btnStart.Enabled = False
timer.Enabled = True
Catch ex As Exception
MsgBox("Error in connecting to response queue")
mqQueue1.Close()
mqQMgr.Disconnect()
End Try
Catch ex As Exception
MsgBox("Error in connecting to request queue")
mqQMgr.Disconnect()
End Try
Catch ex As Exception
MsgBox("Error in connecting to queue manager")
End Try
End If
End Sub
Private Sub getANDput()
Dim cont = True
Do
Dim mqMsg As MQMessage
Dim mqGetMsgO As MQGetMessageOptions
mqMsg = New MQMessage()
mqGetMsgO = New MQGetMessageOptions()
mqGetMsgO.WaitInterval = 15000
mqGetMsgO.Options = MQC.MQGMO_WAIT + MQC.MQGMO_FAIL_IF_QUIESCING
Try
mqQueue1.Get(mqMsg, mqGetMsgO)
Dim msgLen As Integer
msgLen = mqMsg.MessageLength
If (msgLen > 0) Then
Dim mqPutMsgO As MQPutMessageOptions
mqMsg.Format = MQC.MQFMT_STRING
mqPutMsgO = New MQPutMessageOptions()
Try
mqQueue2.Put(mqMsg, mqPutMsgO)
Catch ex As Exception
MsgBox("Error in putting message into queue")
End Try
End If
cont = True
Catch ex As Exception
cont = False
End Try
Loop While cont = True
End Sub
Private Sub timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer.Tick
timer.Enabled = False
getANDput()
timer.Enabled = True
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
timer.Enabled = False
mqQueue1.Close()
mqQueue2.Close()
btnStart.Enabled = True
btnStop.Enabled = False
End Sub
Private Sub frmHost_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
Try
timer.Enabled = False
mqQMgr.Disconnect()
Catch ex As Exception
End Try
End Sub
Private Sub frmHost_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
Try
timer.Enabled = False
mqQMgr.Disconnect()
Catch ex As Exception
End Try
End Sub
'Private Sub frmHost_Mouse() Handles MyBase.Activated, MyBase.Deactivate
' While (btnStart.Enabled = False)
' getANDput()
' Sleep(5000)
' End While
'End Sub
End Class
|
Timer interval is 100ms.
I would like to stop it anytime i want.
My problem: When i press the start button, it does take and put back from the same queue. But my form seems to be whiteout, eventhough the process is still running. I would like the click the stop button to stop the process? Any suggestion on what is the error of my code??? |
|
Back to top |
|
 |
exerk |
Posted: Thu Jul 08, 2010 1:24 am Post subject: |
|
|
 Jedi Council
Joined: 02 Nov 2006 Posts: 6339
|
Moving to a more appropriate forum... _________________ It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys. |
|
Back to top |
|
 |
gbaddeley |
Posted: Thu Jul 08, 2010 6:09 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
The get / put loop may not be relinquishing control back to Windows so that it can process messages for events like mouse clicks.
Maybe you should call DoEvents in the loop somewhere.
My experience with MQGET in VB 5 was that it did relinquish control internally while waiting for a message to arrive. _________________ Glenn |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|