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 » Sample MS VC/C++ using PCF

Post new topic  Reply to topic Goto page Previous  1, 2, 3
 Sample MS VC/C++ using PCF « View previous topic :: View next topic » 
Author Message
PeterPotkay
PostPosted: Thu Jun 16, 2005 5:08 pm    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7723

Here's how the #s can be way different:

Put 1000 messages to a queue, and don't do any MQGETs. Enqueu is 1000, dequeue is 0.

Put 1 messages on a queue, MQGET it under syncpoint, MQBACK it to the queue, MQGET it under syncpoint, MQBACK it to the queue, MQGET it under syncpoint, MQBACK it to the queue, MQGET it under syncpoint, MQBACK it to the queue, etc.... The Enque count will be 1, the dequeue count will be 1000.
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Jun 16, 2005 5:13 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Also, are you clearing your response bag between mqExecutes?

It might be best to start with a new one each time.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
klamerus
PostPosted: Thu Jun 16, 2005 5:28 pm    Post subject: Reply with quote

Disciple

Joined: 05 Jul 2004
Posts: 199
Location: Detroit, MI

Well, this is just a stupid tiny queue I have on my laptop. All the enqueues are from puts using one of the IBM demos and all the gets are from another one.

Clearly I'm not smart enough on this stuff to do MQBACK or syncs .


My program doesn't clear. It runs ones and exits. The code I'm using now follows (it's short):

#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 );
}

Each time I run this I get the same results.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
klamerus
PostPosted: Fri Jun 17, 2005 1:49 pm    Post subject: Reply with quote

Disciple

Joined: 05 Jul 2004
Posts: 199
Location: Detroit, MI

Well, now I'm puzzled.

I deleted and recreated the queue I thought I'm trying to reset (Test1) with this code and I'm still getting the same values in the bag of 17 enqueues and 437 dequeues.

I'm thinking the code is making a valid request, just not a reset request or just not something else (perhaps I'm reading values of something that's not an enqueue or dequeue.

I get errors when I tried to run this while the queue was gone as well (in between the delete and recreate) and that failed on the mqExecute, so I'm clearly trying to do the requests against the right queue. Perhaps the bags aren't getting the values correctly or something.

Any ideas on what might be wrong with this code?
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
klamerus
PostPosted: Fri Jun 17, 2005 2:17 pm    Post subject: Reply with quote

Disciple

Joined: 05 Jul 2004
Posts: 199
Location: Detroit, MI

jefflowrey previously said to count the fields listed in the response.

Is there a way to do this, or is this rhetorical? I'm thinking I'm reading values from the wrong variable or item or even the wrong bag.

I would think that if the command is succeeding (and it's not failing), and if it doesn't work if the queue isn't there, then perhaps I'm not doing the right setup in advance or I'm not reading the right data in response.

The other possibility is that the values in the response bag aren't getting set, but I would only expect that to be true if the instructions weren't right. Anything else would seem to be an MQ error, and I'm sure that's not what's going on.
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:06 am    Post subject: Problem Solved!!! 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
klamerus
PostPosted: Tue Jun 21, 2005 9:07 am    Post subject: Thanks Reply with quote

Disciple

Joined: 05 Jul 2004
Posts: 199
Location: Detroit, MI

Thanks to everyone here who helped on this as well, it was very much appreciated and without the help we wouldn't have gotten to where we had hit this last hurdle.
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 Goto page Previous  1, 2, 3 Page 3 of 3

MQSeries.net Forum Index » IBM MQ API Support » Sample MS VC/C++ using PCF
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.