I have a java batch process which publishes message processing to MQ. MDB associated with the queue processes the message. Each message will have 10 records. I need to update a database table to keep track of the records processed, successful and failures. There will be only one row in table for each batch run. So the problem is that since multiple instances of MDB are trying to update, we are facing concurrency issues. We tried with row-level locking as well. But the issue still exists.
I am looking for a solution where I can keep track of the counter on the java side and then do a single update after reaching certain threshold. Lets say 500 messages were published. Each message processes 10 records.开发者_如何学运维 The MDB should update this counter after processing all records within this message. The counter will then spawn a thread (if threshold is met) that will update the database.
Please let me know what options are available to me.
App Server - WAS 5.6, DB2 9.1 on Z/OS. Access to DB2 is through SP.
Thanks!
Have you tried doing the update entirely on the DB server? For example:
UPDATE COUNT_TABLE SET COUNTER = COUNTER + 1 WHERE ...
The DB server should be able to manage concurrent update statements like this.
The simplest solution would be to have only a single MDB instance running and your concurrency problem disappears.
This would be a little slower, since you will be doing DB updates of 10 at a time instead of your proposed 500, but unless this is a problem, I would just keep it simple.
精彩评论