I defined the TD queue as the following : DFHDCT TYPE=INTRA, DESTID=STMD, DESTRCV=PH, DESTFAC=FILE, TRIGLEV=1, TRANSID=STMD When I test to put messge to TDq(STMD) with TPNS,I see multi STMD running. I think the STMD should be initiated only once because I read the TDq until Qzero. If I change the DESTRCV=LG, the STMD is correctly initiated. How can I solve (without changing DESTRCV=LG)? Any suggestion will be appreciated. (I'm running CICS410)
I don't see why you cannot just change to DESTRCV=LG as this gives the behavour you require.
LG will start a Transaction when the number of records exceeds theTRIGLEV and also put an internal ENQ on the TDQ on its use which stops additional activity to the Queue. This is so that if the transaction abends, the contents of the Queue can be safely recovered to what it was at the start of the transaction.
PH will do similar sort of recovery activity, but the locking does not occur. This means that a different behavour applies to recovery at emergency restart time, for example. As this means you can get multiple transactions (depending upon the trigger level) and one can get into a situation whereby on recovery the processing of the TDQ is not as expected depending on when/how a failure occurs. In other words, only an individual record in the TDQ is being locked (so it will only be visible to a given transaction) but the Queue itself is still open to activity.
This is all discussed in the RDO book. In general, I always define TDQs with LG to get a properly predictable behavour.
It also strikes me that the application reading the TDQ should be prepared to accept an error in reading the TDQ for the 1st time as well as subsequent times (but it should already be doing this). You probably need to consider not doing a XC SYNCPOINT after each record is read from the TDQ only when you find an empty queue. This will ensure that the aforementioned locking works as expected.
It might be that TPNS loads the TDQ quicker than CICS can empty it. Thus, without the locking implied by LG, you are getting a transaction initiated for each record placed in the TDQ. If the started transaction is reading more than one record from the TDQ, the later ones will find an empty TDQ - which I suspect they are not expecting. You need to consider if this is merely an artifact of TPNS or will happen in real activity.
This was first published in August 2002