|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
vb6 groupstatus and MQGS_LAST_MSG_IN_GROUP need help |
« View previous topic :: View next topic » |
Author |
Message
|
jeannie |
Posted: Thu Feb 16, 2006 9:47 pm Post subject: vb6 groupstatus and MQGS_LAST_MSG_IN_GROUP need help |
|
|
Novice
Joined: 10 Jan 2006 Posts: 18
|
How in VB6 (using activex) do you declare and then test the groupstatus?
I am retrieving messages that are in a group and need to check for the last message in the group: MQGS_LAST_MSG_IN_GROUP. According to IBM docs groupstatus is a "field" ... not a property? So what does it belong to?
I have tried:
Dim gstatus As String ' message header group status
and
Dim gstatus As Integer
Some sample programs showed it declared as char, IBM declared an int.
Anyway, I've then tried
gstatus = gmo.groupStatus
and then
If gstatus = MQGS_LAST_MSG_IN_GROUP Then
VB6 wants an object to prefix MQGS_LAST_MSG_IN_GROUP
OR, do I have to use Messageflags? If so, how is the structure handled in VB6? I am new to vb6 and new to MQseries.
If you want more, below is what I have done so far ...
Thanks to anyone for any help
-jeannie
Private Sub Form_Click()
'*******************************************************************************
'* This simple example illustrates how to put and get a WebSphere MQ message to
'* and from an MQ message queue. The data from the message returned by the get
'* is read and compared with that from the original message.
'*******************************************************************************
Dim MQSess As MQSession '* session object
Dim QMgr As MQQueueManager '* queue manager object
Dim Queue As MQQueue '* queue object
Dim GetMsg As MQMessage '* message object for get
Dim gmo As MQGetMessageOptions '* put message options
Dim GetMsgStr As String '* get message data string
Dim openOptions As Integer '* open queue options
Dim gstatus As Integer ' message header group status
Dim firstmsg As Boolean ' flag for message to file
Dim filename As String ' name of output file
Dim cnter As Integer ' number to use to create filename
'*******************************************************************************
'* Handle errors
'*******************************************************************************
On Error GoTo HandleError
'*******************************************************************************
'* Initialize the current position for the form
'*******************************************************************************
CurrentX = 0
CurrentY = 0
'*******************************************************************************
'* Create the MQSession object and access the MQQueueManager and (local) MQQueue
'*******************************************************************************
Set MQSess = New MQSession
Set QMgr = MQSess.AccessQueueManager("UTQM")
openOptions = MQOO_OUTPUT Or MQOO_FAIL_IF_QUIESCING Or MQOO_INPUT_AS_Q_DEF
Set Queue = QMgr.AccessQueue("GETQ.XML.DOWNLOAD", openOptions)
'*******************************************************************************
'* Create a new MQMessage object for use with get
'* create an MQGetMessageOptions object and get the message.
'*******************************************************************************
Set GetMsg = MQSess.AccessMessage()
Set gmo = MQSess.AccessGetMessageOptions()
gmo.Options = MQGMO_FAIL_IF_QUIESCING
gmo.Options = gmo.Options + MQGMO_SYNCPOINT
gmo.Options = gmo.Options + MQGMO_COMPLETE_MSG
gmo.Options = gmo.Options + MQGMO_CONVERT
gmo.Options = gmo.Options + MQGMO_WAIT
gmo.WaitInterval = 5000
gmo.Options = gmo.Options + MQGMO_ALL_MSGS_AVAILABLE Or MQGMO_ALL_SEGMENTS_AVAILABLE
gmo.Options = gmo.Options + MQGMO_LOGICAL_ORDER
gmo.MatchOptions = MQMO_MATCH_GROUP_ID
firstmsg = True
Do While True
Set GetMsg = MQSess.AccessMessage()
MQSess.ExceptionThreshold = 3 '* process GetMsg errors in line
Queue.Get GetMsg, gmo
MQSess.ExceptionThreshold = 2
If MQSess.ReasonCode <> MQRC_NO_MSG_AVAILABLE Then
'get header and check group status
gstatus = gmo.groupStatus
GetMsgStr = GetMsg.MessageData
If firstmsg Then
Do While True ' loop to get a unique file name
cnter = cnter + 1
filename = "f:\lib25\uvlrecv\in" + LTrim(Str(cnter)) + ".xml"
If Dir(filename) Then
Else
Exit Do
End If
Loop
Open filename For Output As #2
firstmsg = False
End If
Write #2, GetMsgStr
'***********************************************
'WHAT DO I DO HERE ???????????
If gstatus = MQGS_LAST_MSG_IN_GROUP Then
Close #2
firstmsg = True
End If
Else
Exit Do
End If
Loop
Exit Sub
'*******************************************************************************
'* Handle errors
'*******************************************************************************
HandleError:
Dim ErrMsg As String
Dim StrPos As Integer
Cls
BackColor = RGB(255, 0, 0) '* set to red for error
Print "An error occurred as follows:"
Print ""
If MQSess.CompletionCode <> MQCC_OK Then
ErrMsg = Err.Description
StrPos = InStr(ErrMsg, " ") ' * search for first blank
If StrPos > 0 Then
Print Left(ErrMsg, StrPos) '* print offending MQAX object name
Else
Print Error(Err) '* print complete error object
End If
Print ""
Print "WebSphere MQ Completion Code = " & MQSess.CompletionCode
Print "WebSphere MQ Reason Code = " & MQSess.ReasonCode
Print "(" & MQSess.ReasonName & ")"
Else
Print "Visual Basic error: " & Err
Print Error(Err)
End If
Exit Sub
End Sub
Private Sub Form_Paint()
Cls
Print "Click anywhere within this form to run the test."
Print ""
End Sub
... |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Feb 17, 2006 1:57 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Jeannie, I think you are confusing the gmo options which will influence the behavior of your get command with the flags set on the MQMD which carry information on your message.
Read up in the programming manual the information about gmo flags and fields on the MQMD. This will clear up the confusion.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
jeannie |
Posted: Fri Feb 17, 2006 10:00 am Post subject: |
|
|
Novice
Joined: 10 Jan 2006 Posts: 18
|
i agree and i did. a field in my lexicon is an element of a table or structure. a property is a descriptor of an object.
So I searched some more. The MessageFlags property is "echoed to the Segmentation field in MQGMO", so that is how one can read the gmo to get the value even if it does seem weird.
I'm now trying to work through MessageFlags.
I still do not see anything that makes sense on GroupStatus. I cannot get MQMF_LAST_MSG_IN_GROUP to be read properly. I tested <> 0, but that does not work.
yikes, this should have been so simple.
-jeannie |
|
Back to top |
|
 |
Vitor |
Posted: Sun Feb 19, 2006 5:25 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Jeannie,
I think this is potentially so simple, but you may still have a little confusion sloshing round.
The MQMF_LAST_MSG_IN_GROUP is used by the putting application to indicate that the group has ended. In your getting application all you should need to do is specify MQGMO_ALL_MSGS_AVAILABLE and you won't get any messages returned from the queue until the last one has been put. You can test MQMD.GROUPID to see if the group has ended (is it the same as the id from the previous message or use MQMO_MATCH_GROUP_ID as a match option on the get), and you have access to the MQGMO_LOGICAL_ORDER, MQMO_MATCH_MSG_SEQ_NUMBER, MQGS_MSG_IN_GROUP, etc, etc....
All laid out in the Application Programming Guide, and explained far better than I ever could.
Hope this helps  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jeannie |
Posted: Mon Feb 20, 2006 4:14 pm Post subject: |
|
|
Novice
Joined: 10 Jan 2006 Posts: 18
|
Hi,
I ended up using the MessageFlags, testing for MQMF_MSG_IN_GROUP + MQMF_LAST_MSG_IN_GROUP.
Since i had MQGMO_LOGICAL_ORDER and MQGMO_ALL_MSGS_AVAILABLE, etc. as some of the get options, all the little messages fell into place, and I now have complete xml files that had been returned segmented.
thanks,
jeannie |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Feb 20, 2006 5:54 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Great jeannie. Congrats. Thanks for letting us know.  _________________ MQ & Broker admin |
|
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
|
|
|
|