CSLA and distributed transactionsCSLA and distributed transactions
Old forum URL: forums.lhotka.net/forums/t/4968.aspx
Cosmin posted on Thursday, June 12, 2008
Hi,
Just a question, I haven't tried it yet:
Say that I have a root object and some MSMQs to update when I press the save button. How would the code look like in the save click event handler?
Never worked with distributed transactions before. Do you need to start the transaction manually?
Thanks,
Cosmin
RockfordLhotka replied on Thursday, June 12, 2008
In the CSLA model, you would interact with MSMQ inside the DataPortal_XYZ method, not the Save() method. "Server-side" resources like databases and queues should only be used within a DataPortal_XYZ method.
Then all you need to do is put the standard CSLA Transactional attribute on your DataPortal_XYZ method and indicate if you want EnterpriseServices or TransactionScope style transactions (probably depends on whether all your server resources have a provider for TransactionScope), and CSLA takes care of the rest for you.
Cosmin replied on Friday, June 13, 2008
All right, but in case you don't want to mess with other resources inside you business object? There might be situations where you want to do different things at different times like:
CustomerBO.Save()
msmq.Send()
otherThings.Update()
or
CustomerBO.Save()
SomeOtherResource.Update()
But I think for these situations one just needs to create another business objects and encapsulate the operations in the dataportal_xxx methods, right?
Cosmin.
RockfordLhotka replied on Friday, June 13, 2008
Yes, if you want to interact with numerous business objects
within the same logical operation (transactional or not), you should create
another business object (often a Command object) that orchestrates the
interactions within a DataPortal_XYZ method.
Rocky
Copyright (c) Marimer LLC