|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
VB.NET: read XML form queue |
« View previous topic :: View next topic » |
Author |
Message
|
PieterV |
Posted: Wed May 31, 2006 3:17 am Post subject: VB.NET: read XML form queue |
|
|
Disciple
Joined: 04 Jan 2006 Posts: 164 Location: Belgium
|
hello,
i have following message on a queue:
<Broker uuid="d800cf4b-0b01-0000-0080-e0787a422226" label="WBIMBBRT" version="1">
<StatusChange new="Stopped"/>
</Broker>
(this is actualy the status of a Message Broker then i received by subsribing to $SYS/Broker/+/Status)
I have a VB.NET application who needs to read this message from to queue.
But i can't use this message.
The problem is that i still have the RFH2 header in the message.
The only thing i can do is do message.readbytes but then i get:
Code: |
8270723200020002080011700418432323232323232320000004184000136601121159962606711110910997110100628011798108105115104604767111109109971101006260801179879112116628210111697105110801179860478011798791121166260801179879112116627911610410111483117981157911010812160478011798791121166260841111121059962368389834766114111107101114478766737766668284478311697116117115604784111112105996260471121159962320002860109991006260771151006212010910811560477711510062604710999100623232606611411110710111432117117105100613410056484899102529845489848494548484848454848564845101485556559752505050505434321089798101108613487667377666682843432118101114115105111110613449346260831169711611711567104971101031013211010111961348311611111211210110034476260476611411110710111462
|
But what to do with this?
the VB.NET code is:
Code: |
QMGR_T = New MQQueueManager(My.Settings.QM_Test_Name, My.Settings.QM_Test_Channel, My.Settings.QM_Test_Location)
'read Q
Dim openopt As Integer = MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_BROWSE + MQC.MQOO_INQUIRE
Dim getopt As New IBM.WMQ.MQGetMessageOptions
getopt.Options = MQC.MQGMO_BROWSE_FIRST '+ MQC.MQGMO_CONVERT
Q_Status_T = New MQQueue(QMGR_T, My.Settings.QM_Test_StatusQ, openopt, "", "", "")
If Q_Status_T.CurrentDepth > 0 Then
Dim message As New MQMessage()
message.Format = MQC.MQFMT_RF_HEADER_2
message.CharacterSet = 1208
Dim counter As Integer = 0
While counter < Q_Status_T.CurrentDepth
Q_Status_T.Get(message, getopt)
getopt.Options = MQC.MQGMO_BROWSE_NEXT + MQC.MQGMO_CONVERT
counter = counter + 1
End While
Dim length As Integer = message.MessageLength
Dim bytes As Byte() = message.ReadBytes(length)
Dim text As String = ""
Dim i As Integer
For i = 0 To bytes.Length - 1
text = text & bytes(i).ToString
Next
'Dim text As String = message.ReadLine
TextBox1.Text = text
|
Anybody knows what to do?
i looked at XMS, but that doesnt give me a possibility to browse messages (i want to keep them on the queue).
perhaps i could send this message trough a message flow and strip the RFH2 header, but that seems overkill and perhaps not possible, am i wrong?
Pieter |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 31, 2006 5:01 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You really don't want to leave this message on the queue.
You want to use XMS and create a new subscription to this topic.
EVERY SUBSCRIBER GETS IT'S OWN COPY OF A PUBLICATION.
If you *really* need, for some strange reason, to have a queue that gets full of these subscriptions, then create ANOTHER subscription.
Also, remember how MQ headers are built - just like MIME headers. The MQMD is fixed, and returned seperately. Each additional header is in the message body and separated from the next by a blank line. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
PieterV |
Posted: Wed May 31, 2006 5:33 am Post subject: |
|
|
Disciple
Joined: 04 Jan 2006 Posts: 164 Location: Belgium
|
don't worry, i created a new subscription to a new queue.
and i'm reading from that new queue.
now i created a msgflow who deletes the RFH2 header and sets the format to stringformat and that does the trick.
altough i find this solution an overkill. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 31, 2006 5:34 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
But why do you want to leave the messages on the queue? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
PieterV |
Posted: Wed May 31, 2006 5:49 am Post subject: |
|
|
Disciple
Joined: 04 Jan 2006 Posts: 164 Location: Belgium
|
Because it only post a message when
a) the broker starts
b) the broker stops
And the application that i'm writing will not run constantly.
So when i starts up, it must know the last posted state of the broker.
Of course i could save that kind of data in a DB or something but i prefer to keep the data at one place.
Perhaps i will add some lines of code to clean to keep the queue at a maximum depth of 10 messages (all above will be cleaned).
Or i do not, and use the messages to create statistics about the uptime of the broker (what should be 100% ) |
|
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
|
|
|
|