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 » IBM MQ API Support » PCF - MQCMD_INQUIRE_Q_STATUS issue

Post new topic  Reply to topic Goto page Previous  1, 2, 3, 4
 PCF - MQCMD_INQUIRE_Q_STATUS issue « View previous topic :: View next topic » 
Author Message
jefflowrey
PostPosted: Tue Oct 17, 2006 3:11 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Vitor wrote:
Bit of a schoolboy error there if you'll forgive the observation....


Yes, but for someone who started out with the ever classic "I'm new to MQ", he's doing very well.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
IanB
PostPosted: Tue Oct 17, 2006 3:20 am    Post subject: Reply with quote

Apprentice

Joined: 13 Oct 2006
Posts: 43

jefflowrey wrote:
Vitor wrote:
Bit of a schoolboy error there if you'll forgive the observation....


Yes, but for someone who started out with the ever classic "I'm new to MQ", he's doing very well.


Forgiven It's coming together and everyone who's contributed has made it far less painful than I imagine it would be otherwise
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Oct 17, 2006 3:41 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

jefflowrey wrote:
Vitor wrote:
Bit of a schoolboy error there if you'll forgive the observation....


Yes, but for someone who started out with the ever classic "I'm new to MQ", he's doing very well.


I was attempting some constructive criticism, and apologise if it came across as newbie-bashing.

More annoyed with myself than anything for not considering the message matching options as a cause of the 2033
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
IanB
PostPosted: Tue Oct 17, 2006 4:00 am    Post subject: Reply with quote

Apprentice

Joined: 13 Oct 2006
Posts: 43

Vitor wrote:
jefflowrey wrote:
Vitor wrote:
Bit of a schoolboy error there if you'll forgive the observation....


Yes, but for someone who started out with the ever classic "I'm new to MQ", he's doing very well.


I was attempting some constructive criticism, and apologise if it came across as newbie-bashing.

More annoyed with myself than anything for not considering the message matching options as a cause of the 2033


All and any help is appreciated, and I need a slap sometimes to maintain a bit of focus

I'm slightly concerned that I appear to have the same issue I was getting in dotnet. In that every message in dotnet is 168 bytes long regardless of what attributes I request, regardless of it being All or just queue name. In VB I also get 168 byte messages back, further the bytes are identical in both cases :/
This could be an interesting or disasterous development
Back to top
View user's profile Send private message
IanB
PostPosted: Tue Oct 17, 2006 6:33 am    Post subject: Reply with quote

Apprentice

Joined: 13 Oct 2006
Posts: 43

Progress ahoy. I had misused an MQCFIL which is why the attr list wasn't working. I now get variable length messages
Back to top
View user's profile Send private message
IanB
PostPosted: Tue Oct 17, 2006 8:21 am    Post subject: Reply with quote

Apprentice

Joined: 13 Oct 2006
Posts: 43

SUCCESS!

I think I've got a handle on the way it all works now. For your reference here's my complete prototype. It's not production code, but fairly clean.

To make it work you will need to include the BAS files mentioned above InquireQueueStatus(...). They're in the demos that come with the client under the VB directory.

It only returns two parameters, depth and name for simplicity, but from there it is easy to change stuff about and shows by example all the bits the examples didn't show

Thanks for all your help, I hope everything we've done over the last few days benefits someone else

Code start here ------Watch line wrap-------------------------------------------------------------------------


Option Explicit

Private Const MQ_LOG_EXTENT_NAME_LENGTH As Long = 24
Private Const MQIACF_OLDEST_MSG_AGE As Long = 1227
Private Const MQCACF_LAST_PUT_DATE As Long = 3128
Private Const MQIACF_MONITORING As Long = 1258


Private m_hConnection As Long ' handle to queue manager
Private m_hAdminQueue As Long ' handle to system admin command queue
Private m_hReplyQueue As Long ' handle to reply queue
Private m_queueManagerName As String ' name of queue manager
Private m_CompCode As Long ' Completion code
Private m_Reason As Long ' Reason on completion.
Private m_Error As Long ' Some error code

'The request
Private Type PCFInquireQueueStatus
Header As MQCFH 'All PCF messages have an MQCFH (Header)
QueueName As MQCFST 'This is a string definition struct
QueueName_String As _
String * MQ_Q_NAME_LENGTH 'This is the actual string (all are fixed length)
QueueStatusAttrs As MQCFIL 'This one's a number which selects the attributes we want in the message.
QueueStatusAttrs_list As Long
QueueStatusAttrs_list2 As Long
End Type

'a little response NB, it seems queue name has to come first after header!!! Don't know why.
Private Type PCFIQSDEPTHResp
Header As MQCFH
QName As MQCFST
QName_string As String * MQ_Q_NAME_LENGTH
CurrentDepth As MQCFIN
End Type

'a response that doesn't work.
Private Type PCFInquireQueueStatusResp
Header As MQCFH
CurrentDepth As MQCFIN
LastGetDate As MQCFST
LastGetDate_string As String * MQ_DATE_LENGTH
LastGetTime As MQCFST
LastGetTime_String As String * MQ_TIME_LENGTH
LastPutDate As MQCFST
LastPutDate_string As String * MQ_DATE_LENGTH
LastPutTime As MQCFST
LastPutTime_String As String * MQ_TIME_LENGTH
MediaRecoveryLogExtent As MQCFST
MediaRecoveryLogExtent_string As String * MQ_LOG_EXTENT_NAME_LENGTH
OldestMsgAge As MQCFIN
OnQTime As MQCFIL
OpenInputCount As MQCFIN
OpenOutputCount As MQCFIN
QName As MQCFST
QName_string As String * MQ_Q_NAME_LENGTH
QSGDisposition As MQCFIN
QueueMonitoring As MQCFIN
StatusType As MQCFST
UncommittedMsgs As MQCFIN
End Type

'Requires CMQB, CMQCFB and CMQXB bas files from the PCFSAMP project in the vb directory under tools.
Public Function InquireQueueStatus(pQManagerName As String, ByRef rMessage As String, Optional pCall As Boolean = False) As Boolean

Dim ObjectDescription As MQOD '
Dim PCF As PCFInquireQueueStatus ' Request message structure
Dim MessageDescriptor As MQMD '
Dim PutMessageOptions As MQPMO '
Dim GetMessageOptions As MQGMO ' Put message options
Dim GetMessageLength As Long ' Length of message to be put
Dim DataLength As Long '
Dim Response As PCFInquireQueueStatusResp '
Dim strMessage As String * 200 ' the message response if using MQGET
Dim PutMessageLength As Long
Dim respDepth As PCFIQSDEPTHResp

MQ_SETDEFAULTS 'Sets some defaults (lives in one of the MQ bas files)

m_queueManagerName = pQManagerName

MQCONN m_queueManagerName, m_hConnection, m_CompCode, m_Reason

If m_hConnection = 0 Then 'It's a handle, must be non zero for success.
m_Error = -1
Exit Function
End If

'Try and open the queue. If we get a real error abort, but if it's just busy try again until it is free.
Do
MQOD_DEFAULTS ObjectDescription 'All these structures seem to have a set defaults function
ObjectDescription.ObjectQMgrName = m_queueManagerName
ObjectDescription.ObjectName = "SYSTEM.ADMIN.COMMAND.QUEUE" 'This is the admin queue used for all PCF commands
MQOPEN m_hConnection, ObjectDescription, MQOO_INPUT_EXCLUSIVE, m_hAdminQueue, m_CompCode, m_Reason

If m_CompCode = MQCC_OK Then
MQCLOSE m_hConnection, m_hAdminQueue, 0, m_CompCode, m_Reason
'not running
'disconnect
Disconnect
Exit Function
Exit Do
ElseIf m_Reason <> MQRC_OBJECT_IN_USE Then
'error
'disconnect
Disconnect
Exit Function
Exit Do
End If
Loop Until m_CompCode <> MQCC_OK

m_hAdminQueue = 0
Call OpenQueue(m_hAdminQueue, "SYSTEM.ADMIN.COMMAND.QUEUE", m_queueManagerName, MQOO_OUTPUT, m_CompCode)
If m_CompCode = MQCC_OK Then
m_hReplyQueue = 0
Call OpenQueue(m_hReplyQueue, "SYSTEM.DEFAULT.LOCAL.QUEUE", m_queueManagerName, MQOO_INPUT_EXCLUSIVE, m_CompCode)
End If

If m_CompCode <> MQCC_OK Then
Disconnect
Exit Function
Else
End If

If pCall Then 'for testing sometimes I just wanted to Get.
MQMD_DEFAULTS MessageDescriptor
MessageDescriptor.ReplyToQMgr = m_queueManagerName
MessageDescriptor.MsgType = MQMT_REQUEST
MessageDescriptor.ReplyToQ = "SYSTEM.DEFAULT.LOCAL.QUEUE"
MessageDescriptor.Format = MQFMT_ADMIN
MQPMO_DEFAULTS PutMessageOptions
PutMessageOptions.Options = MQPMO_NO_SYNCPOINT 'haven't sussed all these options yet.

MQCFH_DEFAULTS PCF.Header
PCF.Header.Command = MQCMD_INQUIRE_Q_STATUS
PCF.Header.MsgSeqNumber = MQCFC_LAST
PCF.Header.ParameterCount = 2

MQCFST_DEFAULTS PCF.QueueName
PCF.QueueName.StrucLength = MQCFST_STRUC_LENGTH_FIXED + MQ_Q_NAME_LENGTH
PCF.QueueName.Parameter = MQCA_Q_NAME
PCF.QueueName_String = "*"
PCF.QueueName.StringLength = Len(PCF.QueueName_String)


MQCFIL_DEFAULTS PCF.QueueStatusAttrs
PCF.QueueStatusAttrs.Parameter = MQIACF_Q_STATUS_ATTRS
PCF.QueueStatusAttrs.StrucLength = MQCFIL_STRUC_LENGTH_FIXED + 4 + 4 '(4 + 4 = 2 attrs)
PCF.QueueStatusAttrs_list = MQCA_Q_NAME
PCF.QueueStatusAttrs_list2 = MQIA_CURRENT_Q_DEPTH
PCF.QueueStatusAttrs.Count = 2

PutMessageLength = MQCFH_STRUC_LENGTH + MQCFST_STRUC_LENGTH_FIXED + _
MQ_Q_NAME_LENGTH + MQCFIL_STRUC_LENGTH_FIXED + 4 + MQCFIL_STRUC_LENGTH_FIXED + 4 + 4

MQPUTAny m_hConnection, m_hAdminQueue, MessageDescriptor, PutMessageOptions, PutMessageLength, PCF, m_CompCode, m_Reason
End If

'size of struct for MQGetAny, matches RespDepth.
GetMessageLength = MQCFH_STRUC_LENGTH + MQCFIN_STRUC_LENGTH + MQCFST_STRUC_LENGTH_FIXED + MQ_Q_NAME_LENGTH


'GetMessageLength = 200 ' must be same as strMessage for MQGET and longer than the message returned.

Do
MQCFH_DEFAULTS respDepth.Header
MQCFIN_DEFAULTS respDepth.CurrentDepth
MQCFST_DEFAULTS respDepth.QName

respDepth.CurrentDepth.Parameter = MQIA_CURRENT_Q_DEPTH
respDepth.QName.Parameter = MQCA_Q_NAME

MQMD_DEFAULTS MessageDescriptor
MQGMO_DEFAULTS GetMessageOptions
GetMessageOptions.Options = MQGMO_WAIT
GetMessageOptions.WaitInterval = 2500

'MQGETAny will copy the response into any variable passed through, MQGET returns a string.
MQGETAny m_hConnection, m_hReplyQueue, MessageDescriptor, GetMessageOptions, GetMessageLength, respDepth, DataLength, m_CompCode, m_Reason

'MQGET returns a string, handy for debugging.
'MQGET m_hConnection, m_hReplyQueue, MessageDescriptor, GetMessageOptions, GetMessageLength, strMessage, DataLength, m_CompCode, m_Reason

'Do something with the data here
Debug.Print DataLength, respDepth.CurrentDepth.Value, respDepth.QName_string

Loop Until (respDepth.Header.Control = 1) ' Seems to work, I assumed CompCode would come back non zero but it doesn't.

rMessage = strMessage

Disconnect

End Function

Private Sub OpenQueue(Hobj As Long, QueueName As String, QMgr As String, ByVal O_options As Long, m_CompCode As Long)

Dim ObjectDescription As MQOD
MQOD_DEFAULTS ObjectDescription
ObjectDescription.ObjectQMgrName = QMgr
ObjectDescription.ObjectName = QueueName

MQOPEN m_hConnection, ObjectDescription, O_options, Hobj, m_CompCode, m_Reason

End Sub

Private Sub Disconnect()

' Only attempt to disconnect if we are actually connected
If m_hConnection Then
' Close the queue if one is open
If m_hAdminQueue Then
MQCLOSE m_hConnection, m_hAdminQueue, 0, m_CompCode, m_Reason
End If
m_hAdminQueue = 0

' Close the reply queue if one is open
If m_hReplyQueue Then
MQCLOSE m_hConnection, m_hReplyQueue, 0, m_CompCode, m_Reason
End If
m_hReplyQueue = 0

'disconnect
MQDISC m_hConnection, m_CompCode, m_Reason
m_hConnection = 0
End If

End Sub
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2, 3, 4 Page 4 of 4

MQSeries.net Forum Index » IBM MQ API Support » PCF - MQCMD_INQUIRE_Q_STATUS issue
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.