Thursday, June 2, 2016

Design guidelines for concurrent DB connection in SOA

In a Service Oriented Architecture, our web services will be accessed by multiple users concurrently.

Some design guidelines that is useful while designing DB Access Layer for SOA architecture .

1. Don't make your connection static/shared.
2.Always use using statement for DB connection object. Using will act as try catch finally block and closes and disposes the connection object, and this connection object is moved to connection pool that is manged by CLR.
3. If you want to test concurrency in your application, create multiple threads and make multiple request to the exposed services.

 ServiceClientClass client = new ServiceClientClass ();  
 Thread th = new Thread(() => client.CallDBService());  
 th.Start();     

or as in this link:
http://stackoverflow.com/questions/25361706/how-to-test-concurrency-scenarios-in-net

If the connection object is reused by all requests, you will get unexpected errors like
 'Not allowed to change the 'ConnectionString' property. The connection's current state is open.'

Read more here:
http://stackoverflow.com/questions/9705637/executereader-requires-an-open-and-available-connection-the-connections-curren
http://stackoverflow.com/questions/670774/how-can-i-solve-a-connection-pool-problem-between-asp-net-and-sql-server
http://stackoverflow.com/questions/11448335/dispose-the-connection-or-close-the-connection
 

Reactions:

0 comments:

Post a Comment