.NET Forum / .NET Framework / Distributed Applications / February 2004
Transaction management question
|
|
Thread rating:  |
george r smith - 30 Jan 2004 15:36 GMT In the white paper Designing Data Tier Components and Passing Data Through Tiers the following is stated:
Data access logic components typically access data from a single data source. If aggregation from multiple data sources is required, it is recommended to define a separate Data Access Logic Component to access each data source that can be called from a higher-level business process component that can perform the aggregation. ============ Does this mean in the HighLevel component we have something like:
using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction())
then in the first aggregate DALC component we do: // Perform the first update operation SqlHelper.ExecuteNonQuery(trans,CommandType.StoredProcedure, ...);
then in the second aggregate DALC component we do: // Perform the second update operation SqlHelper.ExecuteNonQuery(trans,CommandType.StoredProcedure,...);
Then we have to call two more methods in the aggregate components to do a trans.commit.
Just exactly how do you do this. Also is the HighLevel component a DALC or a business object component.
thanks grs
Steven Cheng[MSFT] - 31 Jan 2004 10:04 GMT Hi Mark,
Thanks for posting in the community! From your description, you seem to feel something unclear with the concept of "Transaction management is centralized to the business process component and does not need to be controlled explicitly by the Data Access Logic Component" which is mentioned in the book <Designing Data Tier Components and Passing Data Through Tiers>, and you are asking about the definite meaning of the "Higher-level business process component", yes? If there is anything I misunderstood, please feel free to let me know.
As for the above questions, here is my understandings: 1. The High-Level component means the Business process component , not the Data Logic Access Component. The DLAC is the low level components to call the row data access apis which finish some certain data manipulations such as Insert, update,delete, select and the DLAC components are stateless which won't contain any stateful infos or context. For example, such code as Open connection, execute sql statement are all in the DLAC components.
However, the High-Level component(Business Logic process component) commonly provide the application business logic dependent operations and some of them are stateful. For example, query the orders for a certain user, or create a order for a certain user.
2. As for the following description: ------------------- Transaction management is centralized to the business process component and does not need to be controlled explicitly by the Data Access Logic Component. If you access multiple data sources from one Data Access Logic Component, you will need the Data Access Logic Component to be the root of transactions, which will introduce additional overhead on functions where you are only reading data. -------------------- I think the "Transaction management" doesn't means the trancation in any Data Access API or database server such as the -------------------- using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) ---------------------- you've mentioned. The "Transaction management" here means some business logic based database processing control or organization. And the "multiple data sources" may means different database, or even different database in different database servers. In such cases, if we provide separate DLAC components for the different datasources, we can put those certain "high level transaction management" in the higher business component rather than in the DLAC components. For example, we have order datas and product datas. Both the two 's datas are distributed in two different database servers. I named one is server "Local", another is "Remote". Now in two cases: 1). I provide separate order DLACs and product DLACs for the different datasource(Local and remote) which means I need 4 DLACs, they are DLAC_order_local,DLAC_order_remote, DLAC_product_local, DLAC_product_remote. Then when I need to retrieve orders or products info from a certain server, we need to provide determination for which DLAC to use, the determination operation can be centralized to the business process component which uses the order and product's DLAC components, just like: if ( local needed) { call DLAC_order_local call DLAC_order_remote ...// other DLAC for local } else { call DLAC_product_local call DLAC_product_remote ...// other DLAC for remote }
But in the DLAC, since one DLAC is only one datasource concerned, not such determination operations needed.
2) If I provide a single DLAC component for both remote or local datasource based order data accessing or product data accessing. I have to put the logic determination into the DLAC compoenents. For example , in Business logic component we use :
if ( local needed) { call DLAC_order_mixed( local param) call DLAC_order_mixed( local param)
...// other DLAC for mixed } else { call DLAC_order_mixed( remote param) call DLAC_order_mixed( remote param)
...// other DLAC for mixed }
In each DLAC, we need to provide the datasource select determination such as: if ( local param pass in) { create local connection ... } else { create remote connection .... }
Then, if we add more DLAC components such as employee, customer.... The overhead of such "Business Transaction management" will increase as well. Do you think so?
Please check out the above suggestions. If you have any questions or have any different opinions on it, please feel free to post here. I'll be willing to discuss it with you.
Regards,
Steven Cheng Microsoft Online Support
 Signature Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
george r smith - 02 Feb 2004 15:13 GMT Steven,
Thank you, but if I have a transaction that must be completed in its entirety or I have to roll it back, where do I put the conn.BeginTransaction()) in order to be able to roll back the updates in two or more DALC components, that is my question. How and where do I put the conn.BeginTransaction() and its remaining parts.
I am only using one database on one server. thanks again
george
> Hi Mark, > [quoted text clipped - 24 lines] > ------------------- > Transaction management is centralized to the business process component and
> does not need to be controlled explicitly by the Data Access Logic > Component. If you access multiple data sources from one Data Access Logic [quoted text clipped - 91 lines] > (This posting is provided "AS IS", with no warranties, and confers no > rights.) Steven Cheng[MSFT] - 03 Feb 2004 14:12 GMT Hi George,
Thanks for your followup. As for the question you mentioned in the reply, here is my suggestion: As for the "conn.BeginTransaction()" you mentioned, this is the ADO.NET transaction API, it is single connection based. So generally , based on the patterns described in the article, we need to put such transaction in DLAC component. However, as for your situation that you only have one connection, I think that you can expose an Interface of the DLAC component so as for the higher-level component(Business logic process component) to call the interface, so that this Transaction can be controled in the higher level. In addtion, there're other approachs to provide more widely and higher level transaction controling, for example the service component (integrate the COM+ transaction service into dotnet), for more detailed description, here are some tech reference on such topic:
#Transaction Control http://msdn.microsoft.com/library/en-us/dnbda/html/bdadotnettransact1.asp?fr ame=true
#Processing Transactions http://msdn.microsoft.com/library/en-us/cpguide/html/cpconprocessingtransact ions.asp?frame=true
#Heterogeneous Distributed Transaction Implementation http://msdn.microsoft.com/library/en-us/f_and_m/html/vxconheterogeneousdistr ibutedtransactionimplementation.asp?frame=true
Please check out the preceding suggestions. If you have any questions, please feel free to post here.
Regards,
Steven Cheng Microsoft Online Support
 Signature Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Steven Cheng[MSFT] - 05 Feb 2004 09:03 GMT Hi George,
Have you had a chance to check out my suggestions or have you got any ideas on this issue? If you have any questions, please feel free to post here.
Regards,
Steven Cheng Microsoft Online Support
 Signature Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
george r smith - 05 Feb 2004 22:50 GMT Steven,
I am playing with code now. So far I am looking at two possibile paths.
1. In a DALC I will use one begin/end transaction to update several tables. 2. Use a stored procedure to handle the begin/end transaction. This was recommended in one of MS white papers.
I built serveral datasets and passed them to a DALC but I don't know if this makes sense as I believe that I have to parse the datset before I call a stored procedure so what good was the dataset.
Also I can't not see yet who you would pass in the data for three tables to one stored procedure and have the procedure pass the data to other stored procedures. grs
> Hi George, > [quoted text clipped - 9 lines] > (This posting is provided "AS IS", with no warranties, and confers no > rights.) Steven Cheng[MSFT] - 06 Feb 2004 12:23 GMT Hi George,
Thanks for your response. As for the question you mentioned in the reply, I think the both twos are OK. Since the Tranaction apis of ADO.NET should be put in level components(the DALC component), you just use them as you used to. And you mentioned that you passed serveral datasets to a DALC(as param of a certain method?), are those datasets all concerned to each other in the certain DALC's method? The DALC is a small dataaccess unit. In it, since all the manipulation are for the same datasource, you can use the conn.BeginTransaction() when needed. And in another DALC, it also has its own exposed interfaces and in each of these interfaces ,you use the ADO.NET transaction api such as "conn.BeginTransaction()", or rollback as you need, do you think so?
Regards,
Steven Cheng Microsoft Online Support
 Signature Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Steven Cheng[MSFT] - 10 Feb 2004 08:59 GMT Hi George,
Have you got any further progress on this issue? If you have any questions on it, please feel free to post here.
Regards,
Steven Cheng Microsoft Online Support
 Signature Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Dilip Krishnan - 11 Feb 2004 15:10 GMT George, Have you tried looking at enterprise services in .net. I think thats much easier to manage and control using attributes than phsyically creating transactions adn commiting and rolling back. If you need help with that let me know Thanks
> In the white paper Designing Data Tier Components and Passing Data Through > Tiers [quoted text clipped - 32 lines] > thanks > grs
 Signature Regards, Dilip Krishnan dilip removethis @ msn.com
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|