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 Java / JMS » About Commit and rollback

Post new topic  Reply to topic Goto page 1, 2  Next
 About Commit and rollback « View previous topic :: View next topic » 
Author Message
scar
PostPosted: Tue Feb 01, 2005 3:34 pm    Post subject: About Commit and rollback Reply with quote

Centurion

Joined: 23 Jun 2004
Posts: 145

HI
My application puts a message to a queue, from there i need to update a database.
I had atriggered application running on that queue, so that it gets the message and updates the database.

There is no error handling at all.

once I get the message from the Q and if the db is down , or if an exception is thrown because of any thing the message is lost.

I have read somthing about commit and rollback, but I dont know how to implement.

what happens to the message when roll back occurs.
does it go back to the same Q.
If so will it trigger the application again.


Thanks
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Feb 01, 2005 8:32 pm    Post subject: Reply with quote

Grand High Poobah

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

What environment are you programming in.
Where is your MQ server ?
We need more details on the scenario....
Are we talking about JMS ??
Back to top
View user's profile Send private message Send e-mail
scar
PostPosted: Wed Feb 02, 2005 3:30 am    Post subject: Reply with quote

Centurion

Joined: 23 Jun 2004
Posts: 145

Its UPES implementation.
WorkFlow puts a message to a queue on FMCQM.
Work Flow is on AIX.
From the q a triggered application gets the message parses the required information and updates db2.
Trigger type is every.

my concern is what if the db is down.(the message will be lost)
Back to top
View user's profile Send private message
bower5932
PostPosted: Wed Feb 02, 2005 7:11 am    Post subject: Reply with quote

Jedi Knight

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

You didn't mention the language you are using. It sounds like you need to do a two-phase commit with the Qmgr and database. You'll use the syncpoint option to get your message and make your database update. If the database update fails, you rollback and your message stays on the queue. You'll probably need to add some logic into your program to handle the fact that you don't want to retry forever or immediately (ie, a backout queue). There is a small sample that does this at:

http://www.developer.ibm.com/tech/sampmq.html

Look for mqdb2.sqc or mqdb2log.java.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
scar
PostPosted: Wed Feb 02, 2005 7:30 am    Post subject: Reply with quote

Centurion

Joined: 23 Jun 2004
Posts: 145

so if the message is backed out then again it triggers the application(an infinite loop until the exception is gone).

is there any parameter that says if backed out put to a BACKUP q
(if we specify the BOQNAME on the q --- The qmgr doesnt do any thing)
or should it be done through API(MQPUT).


I am using JAVA
Back to top
View user's profile Send private message
EddieA
PostPosted: Wed Feb 02, 2005 8:13 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Quote:
is there any parameter that says if backed out put to a BACKUP q

No. You would have to write that logic into your application, by checking the Backout Count.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Feb 02, 2005 8:19 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Also, you should not use Trigger Type = Every.

It is not guaranteed to trigger on every new message.

You should trigger on FIRST, process all messages until the queue is empty, and then stop.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
bower5932
PostPosted: Wed Feb 02, 2005 8:39 am    Post subject: Reply with quote

Jedi Knight

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

There are also some samples that show backing out a message at:

http://www.developer.ibm.com/tech/sampmq.html

You can search for backout.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
scar
PostPosted: Thu Feb 03, 2005 3:23 am    Post subject: Reply with quote

Centurion

Joined: 23 Jun 2004
Posts: 145

Quote:
Also, you should not use Trigger Type = Every.



But its a synchronous process.
as soon as the message is put Q it should be processed and response should be sent back.

Also there might not be more than 3 to 4 mesages in a day.

Is the any other way of doing it with out using TRIGGERTYPE = EVERY
Thanks
Back to top
View user's profile Send private message
nathanw
PostPosted: Thu Feb 03, 2005 3:38 am    Post subject: Reply with quote

Knight

Joined: 14 Jul 2004
Posts: 550

i am assuming that yu do not have WBI installed as you could do all this with a simple message flow as if the db was down it would send the message back to the beginning and try again until success or backout is reached

surely once the application takes the message it is outside the mq domain so to speak and in the hands of the application

why not write the application so that if the db is down it keeps the message and retries until succesful or returns the message to a queue for later usage
Back to top
View user's profile Send private message MSN Messenger
jefflowrey
PostPosted: Thu Feb 03, 2005 6:25 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

scar wrote:
Is the any other way of doing it with out using TRIGGERTYPE = EVERY


Yes.

But the Trigger Type doesn't affect how often your program reads messages.

In fact, building your application the way I said will make it process messages FASTER. Here is why. With trigger type= EVERY and your program reading only one message at a time, then every message causes a new JVM to start, your program to load, and then a queue manager connection established, and the queue opened, the message got, the queue closed, the connection closed and the JVM ended. For each and every message.

If you do it the way I said, then the only time the JVM needs to be started, the queue manager connection established,and the queue opened is when the online application hasn't sent any messages for a bit.

You can also code your application to sit in a loop, with FAIL_ON_QUIESCE and with the MQ Get set to WAIT. Then the instant a message comes in, the GET will return from WAIT, and your program can process it.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
scar
PostPosted: Mon Feb 07, 2005 1:52 pm    Post subject: Reply with quote

Centurion

Joined: 23 Jun 2004
Posts: 145

Quote:
You can also code your application to sit in a loop, with FAIL_ON_QUIESCE and with the MQ Get set to WAIT


I understood what you are saying, but i wasnt able to implement it using JAVA API.

If you have any Code snippet can you please post it.
Back to top
View user's profile Send private message
PeterPotkay
PostPosted: Mon Feb 07, 2005 2:23 pm    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

Post YOUR code snippet, and we will tell you what you are doing wrong.
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
scar
PostPosted: Thu Feb 17, 2005 12:43 pm    Post subject: Reply with quote

Centurion

Joined: 23 Jun 2004
Posts: 145

Quote:
Post YOUR code snippet, and we will tell you what you are doing wrong.


This is how I coded it
Does it make any sense or is there a better way of doing it.


while( OutQueue.getCurrentDepth() != 0)
{
MQGetMessageOptions gmo = new MQGetMessageOptions() ;
gmo.options = MQC.MQGMO_WAIT + MQC.MQGMO_FAIL_IF_QUIESCING + MQC.MQGMO_CONVERT + MQC.MQMO_NONE + MQC.MQGMO_SYNCPOINT;
System.out.println("Get Message Options are Set" );
System.out.println("Current depth of the Q = "+ OutQueue.getCurrentDepth());
MQMessage outMessage = new MQMessage();
OutQueue.get(outMessage);

System.out.println ("outMessage");
System.out.println("outMessage.getMessageLength()="+outMessage.getMessageLength());

byte[] b = new byte[outMessage.getMessageLength()];
outMessage.readFully(b);
String replyMsg = new String(b);
System.out.println (" The message is \n" + replyMsg);
if(OutQueue.getCurrentDepth() == 0)
{
System.out.println("Wait Started");
wait(60000);
System.out.println("Wait Ended");
}
}
Back to top
View user's profile Send private message
bower5932
PostPosted: Thu Feb 17, 2005 12:52 pm    Post subject: Reply with quote

Jedi Knight

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

I wouldn't loop based on the current depth of the queue. Try looping on a 2033 (no message available). You could also make your get have a wait and remove your code to wait based on the current depth of the queue.

You want to avoid basing your program around the current depth. Messages that aren't committed show up in this count, and you'll probably face a load of problems in the future because of this.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » IBM MQ Java / JMS » About Commit and rollback
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.