|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Trouble with MQCMD_RESET_Q_STATS |
« View previous topic :: View next topic » |
Author |
Message
|
klamerus |
Posted: Sat Jun 18, 2005 11:35 am Post subject: Trouble with MQCMD_RESET_Q_STATS |
|
|
 Disciple
Joined: 05 Jul 2004 Posts: 199 Location: Detroit, MI
|
Thought I'd start over. The other thread was getting pretty tired.
I've written the program below, which should be resetting and retrieving the states on a queue (Test1) I created on my Window XP laptop.
Trouble is, that while it doesn't generate any errors, it doesn't appear to either reset stats or return them to me. It may be doing a reset (I don't have a tool to show them to check), but it never returns enqueues and dequeues. I always get two values, 17 and 437 (or something like that), even if I create a brand new Test1 queue.
Maybe the bags aren't right, or the parameters, or the values I'm reading from out of the result bag or something.
Help in identifying the flaw in this code would be very, very much appreciated and I'll even put $ behind a "fix" for this.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <cmqc.h>
#include <cmqcfc.h>
#include <cmqbc.h>
void CheckCallResult( MQCHAR *, MQLONG , MQLONG );
int
main(
int argc,
char * argv[ ] )
{
MQHCONN hConn;
MQCHAR qmName[ MQ_Q_MGR_NAME_LENGTH + 1 ] = "";
MQLONG compCode, reason;
MQHBAG adminBag = MQHB_UNUSABLE_HBAG;
MQHBAG responseBag = MQHB_UNUSABLE_HBAG;
MQHBAG qAttrsBag;
MQLONG mqEnqCount, mqDeqCount;
MQLONG numberOfBags, i;
printf( "Display enqueues and dequeues of local queues\n\n" );
if ( argc > 1 )
strncpy( qmName, argv[ 1 ], ( size_t ) MQ_Q_MGR_NAME_LENGTH );
MQCONN( qmName, &hConn, &compCode, &reason );
CheckCallResult( "MQCONN()", compCode, reason );
if ( compCode == MQCC_FAILED )
exit( ( int ) reason );
mqCreateBag( MQCBO_ADMIN_BAG, &adminBag, &compCode, &reason );
CheckCallResult( "mqCreateBag(adminBag)", compCode, reason );
mqCreateBag( MQCBO_ADMIN_BAG, &responseBag, &compCode, &reason );
CheckCallResult( "mqCreateBag(responseBag)", compCode, reason );
mqAddString( adminBag, MQCA_Q_NAME, MQBL_NULL_TERMINATED, "Test1", &compCode, &reason );
CheckCallResult( "mqAddString(Test1)", compCode, reason );
mqExecute( hConn, MQCMD_RESET_Q_STATS, MQHB_NONE, adminBag, responseBag, MQHO_NONE, MQHO_NONE, &compCode, &reason );
CheckCallResult( "mqExecute(MQCMD_RESET_Q_STATS)", compCode, reason );
if ( compCode != MQCC_OK )
exit( ( int ) reason );
mqCountItems( responseBag, MQHA_BAG_HANDLE, &numberOfBags, &compCode, &reason );
CheckCallResult( "mqCountItems(numberOfBags)", compCode, reason );
printf( "There are %d bags in the result collection\n", numberOfBags );
for ( i = 0; i < numberOfBags; i++ )
{
mqInquireBag( responseBag, MQHA_BAG_HANDLE, i, &qAttrsBag, &compCode, &reason );
CheckCallResult( "mqInquireBag(responseBag)", compCode, reason );
mqInquireInteger( qAttrsBag, MQSEL_ANY_SELECTOR, 3, &mqEnqCount, &compCode, &reason );
CheckCallResult( "mqInquireInteger(mqEnqCount)", compCode, reason );
printf( "There are %d enqueues on Test1\n", mqEnqCount );
mqInquireInteger( qAttrsBag, MQSEL_ANY_SELECTOR, 2, &mqDeqCount, &compCode, &reason );
CheckCallResult( "mqInquireInteger(mqDeqCount)", compCode, reason );
printf( "There are %d dequeues on Test1\n", mqDeqCount );
}
if ( adminBag != MQHB_UNUSABLE_HBAG )
{
mqDeleteBag( &adminBag, &compCode, &reason );
CheckCallResult( "mqDeleteBag(adminBag)", compCode, reason );
}
if ( responseBag != MQHB_UNUSABLE_HBAG )
{
mqDeleteBag( &responseBag, &compCode, &reason );
CheckCallResult( "mqDeleteBag(responseBag)", compCode, reason );
}
MQDISC( &hConn, &compCode, &reason );
CheckCallResult( "MQDISC()", compCode, reason );
return( 0 );
}
void
CheckCallResult(
char *callText,
MQLONG cc,
MQLONG rc )
{
if ( cc != MQCC_OK )
printf( "%-50s failed: Completion Code = %d : Reason = %d\n", callText, cc, rc );
else
printf( "%-50s succeeded: Completion Code = %d : Reason %d\n", callText, cc, rc );
} |
|
Back to top |
|
 |
PeterPotkay |
Posted: Sat Jun 18, 2005 12:13 pm Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
Quote: |
(I don't have a tool to show them to check)
|
Download the MO71 Support pack and do a Queue Statistics on the queue in question - it will show. (Sorry, don't know the answer to your coding problem). _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
klamerus |
Posted: Sat Jun 18, 2005 8:26 pm Post subject: |
|
|
 Disciple
Joined: 05 Jul 2004 Posts: 199 Location: Detroit, MI
|
Hmmm.
Well the intrigue continues. I'm encouraged to see that using the tool in MO71 (thanks for the reminder) that the reset I'm issuing is working.
That is, as I put messages on, and get messages off, my test queue (Test1), and running the test program, that the counts of the enqueues and dequeues seen in MO71 do seem right.
So, that re-affirms that the command is working and that the issue is with how to get the values of the enqueues and dequeues that are being reset by my test program. So, it would seem to be an issue of getting the values out of the return values bag or something with the setup of the bag itself.
Since the objective of my progrma is to get the values (not to reset the queues), it doesn't help me bunches to know this, but it does help me focus where the question on my problem is. |
|
Back to top |
|
 |
klamerus |
Posted: Tue Jun 21, 2005 9:04 am Post subject: Solutoin !!! |
|
|
 Disciple
Joined: 05 Jul 2004 Posts: 199 Location: Detroit, MI
|
Well, with some help from IBM (since this stuff isn't very well documented), we were able to get the above bit of code working. I'll update this thread and the other in case others need to do something similar in the future.
We substituted the two statements in our loop where we get data from the results bag to the following:
for ( i = 0; i < numberOfBags; i++ )
{
mqInquireBag( responseBag, MQHA_BAG_HANDLE, i, &qAttrsBag, &compCode, &reason );
CheckCallResult( "mqInquireBag(responseBag)", compCode, reason );
mqInquireInteger( qAttrsBag, MQIA_MSG_ENQ_COUNT, MQIND_NONE, &mqEnqCount, &compCode, &reason );
CheckCallResult( "mqInquireInteger(mqEnqCount)", compCode, reason );
printf( "There are %d enqueues on Test1\n", mqEnqCount );
mqInquireInteger( qAttrsBag, MQIA_MSG_DEQ_COUNT, MQIND_NONE, &mqDeqCount, &compCode, &reason );
CheckCallResult( "mqInquireInteger(mqDeqCount)", compCode, reason );
printf( "There are %d dequeues on Test1\n", mqDeqCount );
} |
|
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
|
|
|
|