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 » Missing Records with C++ API

Post new topic  Reply to topic
 Missing Records with C++ API « View previous topic :: View next topic » 
Author Message
mhubbard
PostPosted: Sun Jan 09, 2005 9:52 am    Post subject: Missing Records with C++ API Reply with quote

Acolyte

Joined: 25 Aug 2004
Posts: 54

I have written an application using the C++ API that is working great...most of the time. But, occasionally, I seem to get queue.put() calls that do not behave correctly. I have been able to capture the behavior with this code:

long lDepth = m_pQueue->currentDepth();
cout << "Depth prior to put is " << lDepth << end;
if ( m_pQueue->put( * pMessage ) )
{
lDepth = m_Queue->currentDepth();
cout << "Depth after put is " << lDepth << endl;
}

And sure enough, on occasion, I get something like this:
Depth prior to put is 0
Depth after put is 0

I am 100% certain that there are no consumers connected to the queue during this test. In my sequence of several records that I write, I have also seen this behavior happen once where the depth was 1 before and after the put.

Does anyone have any ideas about how this can be? What codes am I not checking on after the put that I should be?

Thanks so much
_________________
Michael J. Hubbard
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Sun Jan 09, 2005 10:23 am    Post subject: Re: Missing Records with C++ API Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

mhubbard wrote:
What codes am I not checking on after the put that I should be?


The code you posted didn't check the return or completion code at all.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
kirani
PostPosted: Sun Jan 09, 2005 3:02 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

There are some sample C++ programs on this site as well as on IBM site. Please look at some sample programs to capture Reason Code and Completion Codes.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
mhubbard
PostPosted: Mon Jan 10, 2005 6:29 am    Post subject: Reply with quote

Acolyte

Joined: 25 Aug 2004
Posts: 54

Sorry - I presumed that the boolean returned from the PUT was an indication of success. I have added the following checks with the same result:

long lDepth = m_pQueue->currentDepth();
cout << "Depth prior to put is" << lDepth << endl;
if ( m_pQueue->put( * pMessage, * pPutOptions ) )
{
long lReasonCode = m_pQueue->reasonCode();
long lCompCode = m_pQueue->completionCode();
lDepth = m_pQueue->currentDepth();
long lMessageFlags = pMessage->messageFlags();
long lPersistance = pMessage->persistence();
long lPriority = pMessage->priority();
char buffer[100];
memset(buffer, 0, sizeof(buffer));
ImqString strDate = pMessage->putDate();
strDate.copyOut(buffer, 50, '0');
cout << "Depth after put is " << lDepth << endl;
cout << "Length after put is " << lLength << endl;
cout << "Flags after put are " << lMessageFlags << endl;
cout << "Persistance after put is " << lPersistance << endl;
cout << "Priority after put is " << lPriority << endl;
cout << "PutDate after put is " << buffer << endl;
cout << "REASON CODE is " << lReasonCode << endl;
cout << "Completion CODE is " << lCompCode << endl;
}

Which results in....

Depth prior to put is0
Depth after put is 0
Flags after put are 0
Persistance after put is 2
Priority after put is -1
PutDate after put is 20050110000000000000000000000000000000000000000000
REASON CODE is 0
Completion CODE is 0

The second and subsequent messages seem to go in fine......
Depth prior to put is0
Depth after put is 1
Flags after put are 0
Persistance after put is 2
Priority after put is -1
PutDate after put is 20050110000000000000000000000000000000000000000000
REASON CODE is 0
Completion CODE is 0

Thanks for pointing out that code repository. I did not know it was there and it looks like a great resource. Can anyone suggest any other debugging information that I might look at?

Thanks
_________________
Michael J. Hubbard
Back to top
View user's profile Send private message
mhubbard
PostPosted: Mon Jan 10, 2005 6:58 am    Post subject: An additional clue Reply with quote

Acolyte

Joined: 25 Aug 2004
Posts: 54

In my test, I attempt to put 8 records on the queue.
I end up with only 7.
To clear the queue for the next test, I have been starting my Consumer application which drains the queue.
This consumer application does a get on the queue with an unlimited timeout value.
When I want to start my test again, I just kill this app which does not nicely end sessions or close queues.
I have found that, if I instead use the CLEAR QLOCAL command from within runmqsc to clear the queue, that I get all 8 records on the next test.
_________________
Michael J. Hubbard
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jan 10, 2005 12:06 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Mike,

If you had switched the characteristics of the queue to get(inhibited) before putting your messages you would have seen the full number of 8 messages...
This was most probably due to the fact that your previous application was shut down before releasing any of the resources and/or locks...

Enjoy
Back to top
View user's profile Send private message Send e-mail
mhubbard
PostPosted: Tue Jan 11, 2005 5:54 am    Post subject: Reply with quote

Acolyte

Joined: 25 Aug 2004
Posts: 54

Are you saying that if I have a process doing a get on a queue.
And that process is doing this get with no timeout specified.
And there is even the remotest chance that the process could go down (maybe because of a reboot or something).
That, in order to make sure I don't loose any records, I have to inhibit Get operations, then do a put, then reenable Gets?
And that I must program the consumer side to understand that if it gets a GET_INHIBITED error, it should just try back again later?
I can certainly do that, but it sounds strange.
_________________
Michael J. Hubbard
Back to top
View user's profile Send private message
bower5932
PostPosted: Tue Jan 11, 2005 6:16 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

I'm not sure what he's saying, but I can tell you that it is possible to "lose" messages when you are using MQGETs with a client connection. For example:

- Connect as an WMQ client (This starts an agent on the server)
- Issue MQGET with wait on a queue without any messages and outside of a UOW (this results in the agent on the server waiting in an MQGET)
- Kill your program (The agent doesn't realize that your program died)
- Put a message onto the queue

The MQGET in the agent will now return. The agent will try to send your program the message. The agent realizes your program is gone. The message is outside of a UOW and it is 'thrown away'. However, if you had attempted to MQGET the message in a UOW, the agent would see that your program is gone and rollback the message.

I hope this clarifies rather than clouds the issue.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
mhubbard
PostPosted: Tue Jan 11, 2005 9:38 am    Post subject: Reply with quote

Acolyte

Joined: 25 Aug 2004
Posts: 54

That did it.
Thanks for the patient support.
_________________
Michael J. Hubbard
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » Missing Records with C++ API
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.