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 » How to stop MQ from auto-commiting?

Post new topic  Reply to topic Goto page Previous  1, 2
 How to stop MQ from auto-commiting? « View previous topic :: View next topic » 
Author Message
wschutz
PostPosted: Sat Oct 15, 2005 3:41 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

hop...you're probably right, i just want to eliminate as many unknowns as possible, and if the customer has to open a problem, he's going to have to upgrade the 5.2 client anyways.....
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
asincero
PostPosted: Sat Oct 15, 2005 12:32 pm    Post subject: Reply with quote

Novice

Joined: 13 Mar 2003
Posts: 18

hopsala wrote:
[
I think we are facing a simpler problem here -probably a bug in his code, or the MQGMO_SYNCPOINT not properly set up; Could you post your code here so we can take a look?
....
Btw, when you said "endmqm" did you mean "endmqm -i"? And do you have QMGR_QUIESING specified?


Here's a sample program I wrote that exhibits the same problem:

---8<------------------8<------------------8<------------------8<------------------8<

#include <cmqc.h>
#include <string>
#include <string.h>


MQCHAR* QUEUE_MANAGER = "milcom.queue.manager";
MQCHAR* QUEUE = "FROM_AVINET.QUEUE";

void
mq_error(MQLONG reasonCode)
{
std::cout << "MQ error: " << reasonCode << std::endl;
exit(1);
}

int
main()
{
MQLONG comp_code = 0, reason_code = 0;

MQOD od = { MQOD_DEFAULT };
MQHCONN queue_manager = 0;
MQCONN(QUEUE_MANAGER, &queue_manager, &comp_code, &reason_code);
if (comp_code == MQCC_FAILED) mq_error(reason_code);

MQOD od2 = { MQOD_DEFAULT };
strncpy(od2.ObjectName, QUEUE, sizeof(od2.ObjectName) - 1);
MQHOBJ queue = 0;
MQOPEN(queue_manager, &od2, MQOO_INPUT_AS_Q_DEF + MQOO_FAIL_IF_QUIESCING,
&queue, &comp_code, &reason_code);
if (comp_code == MQCC_FAILED) mq_error(reason_code);

while (true)
{
MQMD md = { MQMD_DEFAULT };
memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId));
memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId));
md.Encoding = MQENC_NATIVE;
md.CodedCharSetId = MQCCSI_Q_MGR;
MQGMO gmo = { MQGMO_DEFAULT };
gmo.Options = MQGMO_WAIT + MQGMO_CONVERT + MQGMO_SYNCPOINT;
gmo.WaitInterval = 5 * 1000;
char buffer[4097];
memset(buffer, 0, sizeof(buffer));
MQLONG msg_len = 0;
MQGET(queue_manager, queue, &md, &gmo, sizeof(buffer) - 1, buffer,
&msg_len, &comp_code, &reason_code);
if (comp_code == MQCC_OK)
{
std::cout << buffer << "\n" << std::endl;
std::cout << "commit? ";
std::string answer;
std::getline(std::cin, answer);
if (answer == "y")
{
MQCMIT(queue_manager, &comp_code, &reason_code);
if (comp_code == MQCC_FAILED) mq_error(reason_code);
}
else
{
MQBACK(queue_manager, &comp_code, &reason_code);
if (comp_code == MQCC_FAILED) mq_error(reason_code);
}
std::cout << "\n" << std::endl;
}
}
return 0;
}

---8<------------------8<------------------8<------------------8<------------------8<

As you can see, I have MQGMO_SYNCPOINT specified and MQOO_FAIL_IF_QUIESCING specified. Also, I did not specify the "-i" option when invoking 'endmqm'.

After each MQGET, the program prompts you if you want to commit or not. At this point, I shut down the queue manager via 'endmqm'. I wait until it is fully shut down, then I answer the question. It doesn't matter if I choose to commit or rollback, because either call fails with a 2009. In any case, however, the message I just MQGET()'ed before I shut down the queue manager is gone.
Back to top
View user's profile Send private message AIM Address
wschutz
PostPosted: Sat Oct 15, 2005 12:55 pm    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Okay, I took your sample, bound it as a client program. I had a queue with seven messages on it, committed two off, shutdown the qmgr, restarted the qmgr and there were 5 left:
Quote:

[wschutz@wschutz tmp]$ runmqsc TEST
5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
Starting MQSC for queue manager TEST.


dis ql(test) curdepth
1 : dis ql(test) curdepth
AMQ8409: Display Queue details.
QUEUE(TEST) TYPE(QLOCAL)
CURDEPTH(7)
end
2 : end

[wschutz@wschutz tmp]$ ./test1015
1

commit? y


2

commit? y


3

commit?
MQ error: 2009
[wschutz@wschutz tmp]$ runmqsc TEST
5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
Starting MQSC for queue manager TEST.


dis ql(test) curdepth
1 : dis ql(test) curdepth
AMQ8409: Display Queue details.
QUEUE(TEST) TYPE(QLOCAL)
CURDEPTH(5)
end
2 : end

Now, this is linux (FC3) with MQ V6.... can you try to upgrade your client and server to FP11 and try it again?
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
asincero
PostPosted: Sat Oct 15, 2005 1:15 pm    Post subject: Reply with quote

Novice

Joined: 13 Mar 2003
Posts: 18

wschutz wrote:
Okay, I took your sample, bound it as a client program. I had a queue with seven messages on it, committed two off, shutdown the qmgr, restarted the qmgr and there were 5 left:


Did you try shutting down the queue manager at the point when my program gives you the "commit?" prompt? If so, is the message it just MQGET()'d still in the queue?

I'll definately try upgrading my MQ libs and server on the development box, but that'll probably have to wait until Monday.
Back to top
View user's profile Send private message AIM Address
wschutz
PostPosted: Sat Oct 15, 2005 1:18 pm    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Quote:
Did you try shutting down the queue manager at the point when my program gives you the "commit?" prompt? If so, is the message it just MQGET()'d still in the queue?
Yes and Yes.
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
asincero
PostPosted: Sat Oct 15, 2005 1:48 pm    Post subject: Reply with quote

Novice

Joined: 13 Mar 2003
Posts: 18

wschutz wrote:
Quote:
Did you try shutting down the queue manager at the point when my program gives you the "commit?" prompt? If so, is the message it just MQGET()'d still in the queue?
Yes and Yes.


Ok ... I've just noticed very strange that seems to imply that the issue I'm seeing has nothing to do with my code at all. Here's what I did:

1. Starting with an empty queue, I stick 5 messages into it using the 'amqsputc' sample program that comes with the SDK. So this means default PUT options are being used, whatever those are.

2. I use 'runmqsc' and display the curdepth to verify that indeed there are 5 messages in the queue.

3. I shut down the queue manager with 'endmqm' and wait until it is shutdown completely.

4. I restart the queue manager with 'strmqm'.

5. I use 'runmqsc' to display the curdepth of the queue again. However, it is now 0!

So shutting the queue manager down causes it to discard any messages that are in a queue it is managing?! That definately does not sound right. Its almost as if those messages being enqueued aren't being committed. But if that is true, then how come those messages are visible to other processes opening the queue? Unless I'm misunderstanding how transactions work, the results of a unit of work should not be visible to anybody else until that unit of work has been committed, no?
Back to top
View user's profile Send private message AIM Address
jefflowrey
PostPosted: Sat Oct 15, 2005 3:25 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

AMQSPUT puts NON-PERSISTANT messages. Except in certain, specific, cases, non-persistant messages do not survive a restart.

Or at best, it puts messages using PERSISTANCE_AS_QDEF.

This has nothing at all to do with syncpoint.

You should read the Application Programming Guide.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
wschutz
PostPosted: Sat Oct 15, 2005 6:15 pm    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

non-persistant messages... well duh...

asincero, please try again with PERSISTENT messages and post your results.....
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
asincero
PostPosted: Mon Oct 17, 2005 6:02 pm    Post subject: Reply with quote

Novice

Joined: 13 Mar 2003
Posts: 18

wschutz wrote:
non-persistant messages... well duh...

asincero, please try again with PERSISTENT messages and post your results.....


Sorry guys ... I got pulled away on another project today and couldn't get to this issue. But it sounds like MQPUT()'ing messages into the queue with the persistent option set is the problem. D'oh! I guess I should read the API guide more carefully.

If I don't post a follow-up, then I guess you can assume that was indeed the problem. Thanks for all the help.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2 Page 2 of 2

MQSeries.net Forum Index » IBM MQ API Support » How to stop MQ from auto-commiting?
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.