[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Database Transaction management across different remoting objects.

timasmith

6/17/2004 2:16:00 AM

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
1 Answer

John Saunders

6/17/2004 9:01:00 AM

0

"Tim Smith" <timasmith@hotmail.com> wrote in message
news:a7234bb1.0406161816.2884e56c@posting.google.com...
> 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.
--
John Saunders
johnwsaundersiii at hotmail