Database Transaction management across different remoting objects.

  • Thread starter Thread starter Tim Smith
  • Start date Start date
T

Tim Smith

Hi,

If I seperate my middle tier (business domain services) into
functional areas, as follows

Application ----> Person Service ---> Database
----> Order Services ---> Database

such that I have a PersonService and an OrderService, each a singleton
server side object, which execute database procedures. I have

Person Order
+AddPerson +AddOrder

My application needs to be able to call both methods within a single
transaction.

At this time I have code as follows
public void AddPerson(PersonModel model) {
GetConnection()
StartDatabaseTransaction()
ExecuteMethod1..n
Commit()
ReleaseConnection()
}

and similar code for AddOrder(OrderModel mode) {
....
}

How do I have my application start the transaction and end the
transaction such as

public void AddPersonAndOrder(PersonModel person, OrderModel order) {
TransactionManager.StartTransaction();
personService.AddPerson(person);
orderService.AddOrder(order);
TransactionManager.CommitTransaction();
}

The application will be on a different node than the business services
(which can be on the same node) and cannot get a database connection.

Currently my remote PersonService and OrderService are server
instantiated thread safe singleton objects with no client data
(perhaps more scalable?)

Is this possible with Singletons- even with EnterpriseServices -
anywhere I can find examples of this?

thanks!

Tim
 
Tim Smith said:
Hi,

If I seperate my middle tier (business domain services) into
functional areas, as follows

Application ----> Person Service ---> Database
----> Order Services ---> Database

such that I have a PersonService and an OrderService, each a singleton
server side object, which execute database procedures. I have

Person Order
+AddPerson +AddOrder

My application needs to be able to call both methods within a single
transaction.

At this time I have code as follows
public void AddPerson(PersonModel model) {
GetConnection()
StartDatabaseTransaction()
ExecuteMethod1..n
Commit()
ReleaseConnection()
}

and similar code for AddOrder(OrderModel mode) {
...
}

How do I have my application start the transaction and end the
transaction such as

public void AddPersonAndOrder(PersonModel person, OrderModel order) {
TransactionManager.StartTransaction();
personService.AddPerson(person);
orderService.AddOrder(order);
TransactionManager.CommitTransaction();
}

The application will be on a different node than the business services
(which can be on the same node) and cannot get a database connection.

You can pass the SqlTransaction around between the layers. It derives from
MarshalByRefObject.
 
Back
Top