About CFTransaction (and Locking): Time-Consuming operations insdide of CFTransaction?
Posted on 2004-09-21
When the user place an order, we currently...
(A) Send the Order Information in a XML Package to the customer (is NOT the user, by the way) using the CFHTTP tag
and only when we receive a confirmation of the order, we....
(B) Save all the information in the Database
(else we just show an error message)
But sometimes there could be a problem, for example, we already did (A) and got a confirmation but then we get a database error or a coldfusion error or something.
now we have differences between our database and the customer database which is very bad.
We thought about using CFTRANSACTION and doing it this way:
We want to...
(a) Open a new transaction (cftransaction)
(b) Insert the order to our database (cfquery or cfstoredproc)
(c) Send the XML to the customer (cfhttp)
When we get a confirmation, we...
(d1) Commit (cftransaction action)
else when we get an error from the customer, or we had any kind of internal error, we...
(d2) Rollback (cftransaction action)
Now the problem is that the CFHTTP Request might take a "long time".
Currently we have a two-minute-timeout set before we cancel the CFHTTP request.
We heard, that you should keep transactions short... Is that too long?
What would happen, if we keep the CFTRANSACTION Tag open including
the CFHTTP operations we do?
What happens if user 1 is placing his order (currently waiting for the CFHTTP reply),
while at the same time, user 2 is trying to place an order?
Would the user (or coldfusion-server) need to wait until the first users transaction
has been commited or rolled back?
If yes, is there any chance to allow concurrent orders but keep the possibility
of rolling back the order (to avoid the problem as described above)?
Thanks in advance!