|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Losing messages in multithreaded Java program |
« View previous topic :: View next topic » |
Author |
Message
|
unkind |
Posted: Thu May 19, 2011 5:28 am Post subject: Losing messages in multithreaded Java program |
|
|
 Newbie
Joined: 19 May 2011 Posts: 1 Location: Russia
|
Hello,
I am trying to write a multithreaded java application that gets messages from queue and inserts them to database.
using ,MQC.MQGMO_SYNCPOINT and MQC.MQGMO_WAIT (with unlimited wait interval) open options.
first of all, I create a thread (t1) that waits a message to come. when it gets it from queue, it creates a second thread (t2) which waits for a next message. at the same time thread t1 tries to insert message to database. after succesfull insert transaction commits. both methods are synchronized, count of active threads is under control.
so, when I try to get 100 messages (for example) from a queue, one or two last of them are lost. queue is empty, but database contains only 98-99 messages. how can I solve this problem?
windows 7, MQ v 7.0, DB2 v 9.5 |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu May 19, 2011 7:36 am Post subject: Re: Losing messages in multithreaded Java program |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
unkind wrote: |
Hello,
I am trying to write a multithreaded java application that gets messages from queue and inserts them to database.
using ,MQC.MQGMO_SYNCPOINT and MQC.MQGMO_WAIT (with unlimited wait interval) open options.
first of all, I create a thread (t1) that waits a message to come. when it gets it from queue, it creates a second thread (t2) which waits for a next message. at the same time thread t1 tries to insert message to database. after succesfull insert transaction commits. both methods are synchronized, count of active threads is under control.
so, when I try to get 100 messages (for example) from a queue, one or two last of them are lost. queue is empty, but database contains only 98-99 messages. how can I solve this problem?
windows 7, MQ v 7.0, DB2 v 9.5 |
Review your threading model and have each thread work an independent connection. _________________ 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
|
|
|
|