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 » Trouble with MQCMD_RESET_Q_STATS

Post new topic  Reply to topic
 Trouble with MQCMD_RESET_Q_STATS « View previous topic :: View next topic » 
Author Message
klamerus
PostPosted: Sat Jun 18, 2005 11:35 am    Post subject: Trouble with MQCMD_RESET_Q_STATS Reply with quote

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
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
PeterPotkay
PostPosted: Sat Jun 18, 2005 12:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
klamerus
PostPosted: Sat Jun 18, 2005 8:26 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
klamerus
PostPosted: Tue Jun 21, 2005 9:04 am    Post subject: Solutoin !!! Reply with quote

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
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » Trouble with MQCMD_RESET_Q_STATS
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.