Author |
Message
|
sonpat |
Posted: Mon Jan 08, 2007 5:59 am Post subject: Using Multiple Threads to perform the SYNC PT. operations |
|
|
Newbie
Joined: 07 Jan 2007 Posts: 2
|
Hi all,
I have the following issue.
We have a scenario where multiple threads can execute the PUT and GET methods in the same MQQueue.
The PUT and GET are being done using SYNC POINT transactions.
When we run PUT method using around 5 threads parallelly, we find that the number of messages in the common queue not equal to the number of threads.
The code is something like this:
// set the PMO to SYNC POINT
pmo = MQC.MQPMO_SET_ALL_CONTEXT | MQC.MQPMO_SYNCPOINT;
queue.put(message, pmo);
queue.close();
queueManager.commit();
// Logger.info("Message PUT successfully");
We are using log4j to log the flow.
We find that the log file shows the log message 5 times(equal to no. of threads). But in the queue we find less than 5 messages. Also the code is placed in try-catch block and we do not get any exceptions also.
When we retried after removing the SYNC POINT option, it works.
But we have to implement SYNC POINT transaction logic.
Please help me in this regard.
Kindly give your valuable comments on this issue.
Regards,
Patrick |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jan 08, 2007 6:01 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
The connection handle is the scope of the unit of work. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
sonpat |
Posted: Mon Jan 08, 2007 6:08 am Post subject: |
|
|
Newbie
Joined: 07 Jan 2007 Posts: 2
|
jefflowrey wrote: |
The connection handle is the scope of the unit of work. |
So do you mean to say that the queuManager object when calls COMMIT,
all the threads are committed no matter what is the status of the PUT method, and thus some of the messages are not being committed.
Waiting for your response.
regards,
Patrick. |
|
Back to top |
|
 |
bruce2359 |
Posted: Mon Jan 08, 2007 1:15 pm Post subject: |
|
|
Guest
|
From the MQ Application Programming Reference: MQCMIT
5. A unit of work has the same scope as a connection handle; all MQ calls that affect a particular unit of work must be performed using the same connection handle. Calls issued using a different connection handle (for example, calls issued by another application) affect a different unit of work. See the Hconn parameter described in MQCONN for information about the scope of connection handles. |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jan 08, 2007 1:21 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
What this means is that you need to use a different QueueManager object in each thread. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
liscerq |
Posted: Tue Feb 06, 2007 4:42 am Post subject: |
|
|
Newbie
Joined: 06 Feb 2007 Posts: 2
|
Hello,
In the 1st post of this message I saw that "sonpat" could do exactly what I want to do...
I am trying to set a a scenario where multiple threads can execute the PUT/ GET methods in the a Write/Read MQQueue. The problem is that the second time a thread tries to:
- write to the same queue, it will fail with "reason code=2018" (when i use MQ_IN_EXCLUSIVE_BLK);
- open the same queue, it will fail with "reason code=0" (when i use MQ_IN_EXCLUSIVE_NOBLK).
Each thread:
1) invokes the MQCONNX() method (with MQCNO_NONE)
2) invokes the MQOPEN() method with:
- MQ_IN_EXCLUSIVE_NOBLK (if waitInterval == 0 )
- MQ_IN_EXCLUSIVE_BLK (if waitInterval >0 )
What i saw is that the MQCONNX "gives back" to each thread a different hConn, but as the MQOPEN method is invoked by the threads, the hConn has the value of the last returned hConn (by MQCONNX).
I would appreciate your help :) |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Feb 06, 2007 4:45 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
What language? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
liscerq |
Posted: Tue Feb 06, 2007 6:11 am Post subject: |
|
|
Newbie
Joined: 06 Feb 2007 Posts: 2
|
|
Back to top |
|
 |
|