|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
TRANSACTION PROBLEM |
« View previous topic :: View next topic » |
Author |
Message
|
5zan |
Posted: Mon Aug 11, 2008 7:48 am Post subject: TRANSACTION PROBLEM |
|
|
Novice
Joined: 08 Jul 2008 Posts: 24
|
i have two diffrent flows each accessing the same table
flow 1 is inserting records into the table .
flow 2 , if it finds any records in the same table fetches them all , processses them and deletes them all .
the sequence of flow2 is as :
FETCH ALL RECORDS
PROCESS ALL RECORDS
DELETE ALL RECORDS
now while flow2 is at the second step i.e processing the records..
Flow 1 write some records in between ...!!!
and then my flow 2 goes to the 3rd step of deleting all records...
Here the records inserted into the table by flow1 get deleted without being processed...
HOW CAN I AVOID THIS ?
I TRIED ATOMIC STATEMENT IN VAIN !
how can i allow only one flow to access the table at a time ?? |
|
Back to top |
|
 |
sridhsri |
Posted: Mon Aug 11, 2008 9:29 am Post subject: |
|
|
Master
Joined: 19 Jun 2008 Posts: 297
|
I think perhaps having table-level locks might prevent this situation. I am not sure how these locks may be obtained though. If you are using JDBC APIs, I am sure there might be some documentation that'll tell you that.
Another option is
1) Introduce another column in the table - a delete flag which is set to 'N' buy flow 1.
2) Flow 2 after reading updates the column to 'Y'
3) A flow3 triggered by a timer or flow2 after completion puts a message in a queue which triggers flows, can delete those records where delete flag is set to 'Y'. |
|
Back to top |
|
 |
5zan |
Posted: Mon Aug 11, 2008 10:43 pm Post subject: yep |
|
|
Novice
Joined: 08 Jul 2008 Posts: 24
|
yes thats an alternative . But i guess there should be something as a locked access to the database in a single thread through the broker !!
Hmmph !!
Any clues ? lemme know plz !  |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Aug 12, 2008 3:06 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Your transaction boundary is not atomic...
The atomic transaction would be:
get 1 record for update (dblock), process the record, delete the record.
What you do is get all records, process records, delete ALL records.... Which is precisely what got you into this mess.
You delete all records instead of deleting the processed records.
Your transaction is not atomic and does not care for threading or multiple threads... either.
You have a nice design problem here... Fix it!  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|