Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a non-transactional component in a transaction

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
while working in COM+ I came across a problem.I have worked on J2EE also and but this problem never arose even under the same conditions.


The scenario
It is a room booking system.
(note as per our architecture all DAN components are non-transactional and DAT are transactional)

I have three componenets taking part in the a single operation and obviously it is a transactional operation

The components are

1) Component BookingDAN(Transaction not supported)
method:checkTimeRange();
Description:checks the time range for a particular room booking is available or not

2) Component BookingDAT(Transaction required)
a) method :addBooking();
Description :adds a particular booking to the database.

b) method :deleteBooking

description : deletes a booking from the database.

3) Component BookingMGR(Transaction required)(Root component of the transaction)

a) method :addBooking();
Description :adds a particular booking to the database(calls the addbooking() method of DAT componenet.

b) method :editBooking

description : Edits a selected booking like(deletes the selected booking and add the new parameters as a new booking)




for addBooking method of the root component(bookingMGR) the sequesnce of the operaion is like this

a)validation of the time range using DAN componenets ckectTimeRange method(remeber DAN componenets are non-transactional)
b)If no booking exists agains the time range then addBooking method of the bookingDAT component is called.

then there are couple of more operation which are irrelevant to the problem so I am not siting them here.

This transaction works perfect


Now the real problem is with the second method of the rootComponenet (editBooking())
the sequence of operation is like following

(logic of edit booking interface:If theere is a booking for Room No:30 from 8:30 to 10:30 the user wants edit this booking and make it a booking from 9:30 to 12 the xisting booking will be deleted and a new booking will be made)

The sequesnce of operation performed by the root componenet's BookingMGR's method edit booking :
a) delete the the existing booking(delete method of bookingDAT componrenet)
b) validate the time range by calling the checkTimeRange of the bookingDAN componenet(please note that this componenet is a non transactional component)
c)add a new booking by calling addBooking method of bookingDAT component.

the problem has two context

when the datasource is SQL Server7 , once this method is called the system crahses

If the database is Oracle8i the then system does not crash but the deletion is not visible to the checkTimeRange method of bookingDAN component
that is if I delete a booking from 10:00 to 11:11 and call the mthod checkTimeRange() for a time range 10:00 to 11:00 it returns true.
only my laptop gave (data source sqlserver) gave the error method~of object~bookingDAN failed.


in that case I gave the DAN componenet (as per our architecture not supposed to be transactional) support tarnsaction attribute and all the problems vanished.

Can some one help me out on this.As my experince goes with EJB this was never an issue.Are we not supposed to use a non-transactional componenet within a transaction or is it because of some other problem.Any help will be highly appreciated.

 
What error(s) are you getting when your systems crashes after calling BookingMGR.editBooking? Is it during the
BookingDAT.addBooking or BookingDAT.deleteBooking step?
Is BookingDAN.checkTimeRange() holding open any resources?

I think the problem is that you may be using checkTimeRange() at a point that the other objects have a resource locked. Thus it will block and you are in a deadlock. Putting checkTimeRange() into the transaction could allow it to read the locked record but you would be breaking the ACID property. For Editing what I would suggest is something like the following.

BookingDAN.checkTimeRange()'check the availability of the new time slot and SetComplete - This object is stateless right?
'if it is available
BookingDAT.addBooking()
BookingDAT.deleteBooking()
'if all is well then SetComplete.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top