|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
MQPutAny message resulting in hex on the queue |
« View previous topic :: View next topic » |
Author |
Message
|
JTski |
Posted: Mon Feb 09, 2004 5:39 am Post subject: MQPutAny message resulting in hex on the queue |
|
|
Novice
Joined: 04 Feb 2004 Posts: 14
|
Hi all,
Can anybody recognize by my code below why when I look at the message i put on the queue it is in hex? Am I missing some options?
Private Sub MQUnivPut(tMsg As udtMsg, _
lExpiry As Long, tSendMessages() As udtPhysicalMessage)
On Error GoTo ErrorHandler
Const wcMethodName As String = "MQUnivPut"
'Declare Variables.
Dim sMsgID As String * 24
Dim nPhysicalIndex As Integer
Dim sAppData As String
Dim PutMsgOpts As MQPMO
Dim MsgDesc As MQMD
nPhysicalIndex = 0
'Set put message defaults
MQPMO_DEFAULTS MQPMO_DEFAULT
PutMsgOpts = MQPMO_DEFAULT
With PutMsgOpts
.Options = MQPMO_SYNCPOINT + MQPMO_SET_IDENTITY_CONTEXT
End With
For nPhysicalIndex = LBound(tSendMessages) To UBound(tSendMessages)
'Set mq message id
sMsgID = Arch.IdMan.CreateGUID & Arch.IdMan.CreateUniqueId
sAppData = tSendMessages(nPhysicalIndex).sApplIDData
'Set message description defaults
MQMD_DEFAULTS MQMD_DEFAULT
MsgDesc = MQMD_DEFAULT
'Modify default where appropriate
With MsgDesc
.Expiry = lExpiry
.CodedCharSetId = 500
.MsgId = sMsgID
.ApplIdentityData = sAppData
.Encoding = 785
.Persistence = MQPER_PERSISTENT
.Format = MQFMT_STRING
End With
'Put message on queue
MQPUTAny Hconn, Hobj, MsgDesc, PutMsgOpts, _
Len(tSendMessages(nPhysicalIndex).sMessage), _
tSendMessages(nPhysicalIndex).sMessage, CompCode, Reason
'Raise error if put failed
If CompCode <> MQCC_OK Then
'Roll back transaction
Call MQUnivCommit(tMsg, False)
'Raise error
Err.Raise CompCode, , "MQUnivPut failed with " & _
"CompCode: " & CompCode & "and Reason: " & Reason
End If
Next
'All message(s) were successfully put, commit transaction
Call MQUnivCommit(tMsg, True)
Exit Sub
ErrorHandler:
Dim tErrorInfo As udtErrorObjectContext
Select Case Err.Number
Case Else
tErrorInfo = GlobalErrorHandler(tMsg, wcClassName, wcMethodName, wcSeveritySevere, wcErrMQQueueFull, Erl, m_tQControl.sRequestQ, m_tQControl.sQueueManager, m_tQControl.sReplyQ)
Err.Raise wcErrMQSendMessageFailed, tErrorInfo.sSource, tErrorInfo.sDescription, tErrorInfo.sHelpFile, tErrorInfo.lHelpContext
End Select
End Sub |
|
Back to top |
|
 |
JasonE |
Posted: Mon Feb 09, 2004 7:21 am Post subject: |
|
|
Grand Master
Joined: 03 Nov 2003 Posts: 1220 Location: Hursley
|
From an internal document - No promises on accuracy
Quote: |
Example 1: A String with MQPUT
VB: MQPUT gHcon, gHobj, md, pmo, buflen, Buffer, CompCode, Reason
Data: "12345678"
Trace: 31 32 33 34 35 36 37 38 : 12345678
Example 2: A string with MQPUTAny
VB: MQPUTAny gHcon, gHobj, md, pmo, buflen, Buffer, CompCode, Reason
Data: "12345678 (MQPUTAny)"
Trace: F4 CB 13 00 13 00 00 00 EC CE 13 00 00 00 00 00 : ôË......ìÎ......
4D 00 44 : M.D
VB: MQPUTAny gHcon, gHobj, md, pmo, buflen, ByVal Buffer, CompCode, Reason
Data: "12345678 (MQPUTAny ByVal)"
Trace: 31 32 33 34 35 36 37 38 20 28 4D 51 50 55 54 41 : 12345678 (MQPUTA
6E 79 20 42 79 56 61 6C 29 : ny ByVal)
Example 3: A structure (10 character and 20 character fields)
VB: MQPUTAny gHcon, gHobj, md, pmo, buflen, myBlock, CompCode, Reason
Data: "12345678, 12345678"
Trace: 31 32 33 34 35 36 37 38 20 20 31 32 33 34 35 36 : 12345678 123456
37 38 20 20 20 20 20 20 20 20 20 20 20 20 : 78
VB: MQPUTAny gHcon, gHobj, md, pmo, buflen, ByVal MyBlock, CompCode, Reason
Data: "12345678, 12345678"
-> trap!
Example 4: A structure with two variable length strings (incorrect)
VB: MQPUTAny gHcon, gHobj, md, pmo, buflen, MyBlock, CompCode, Reason
Data: "12345678, 12345678"
Trace: BC A5 13 00 54 CC 13 00 50 4D 4F 20 01 00 00 00 : ¼¥..TÌ..PMO ....
VB: MQPUTAny gHcon, gHobj, md, pmo, buflen, ByVal MyBlock, CompCode, Reason
Data: "12345678, 12345678"
Trace: 31 00 32 00 33 00 34 00 35 00 36 00 37 00 38 00 : 1.2.3.4.5.6.7.8.
00 00 00 00 00 00 00 00 00 00 00 00 05 00 05 00 : ................
Summary of testing
Strings can be variable length with MQPUT (ByVal on call is redundant, its on the definition).
Strings can be variable length with MQPUTAny and ByVal (Converts string to a C string)
Structures must be a fixed sizes (e.g. string * 16) with MQPUTAny and NOT ByVal
Any data passed to MQ must be data, not pointers or references within VB. On an MQGET these pointers/references would be invalid (may trap). |
|
|
Back to top |
|
 |
JTski |
Posted: Mon Feb 09, 2004 7:28 am Post subject: |
|
|
Novice
Joined: 04 Feb 2004 Posts: 14
|
Thanks Jason.
So apparently if I want to put a string message on the queue I have to use MQPut? Not MQPutAny? Your MQPut example seems to be the only example that placed on the queue the string value you expected it to.
"12345678" |
|
Back to top |
|
 |
JTski |
Posted: Mon Feb 09, 2004 7:35 am Post subject: |
|
|
Novice
Joined: 04 Feb 2004 Posts: 14
|
I used MQPUT instead of MQPutAny and all is working! Thanks for the info Jason, you caused my brain to function more clearly .... lol.
Thanks again. |
|
Back to top |
|
 |
JasonE |
Posted: Mon Feb 09, 2004 7:47 am Post subject: |
|
|
Grand Master
Joined: 03 Nov 2003 Posts: 1220 Location: Hursley
|
I think you can use MQPUTAny + byref too (example 2 part 2) |
|
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
|
|
|
|