Revisiting Transactions

3 views
Skip to first unread message

Martin S

unread,
Jan 6, 2010, 9:30:03 PM1/6/10
to S#arp Architecture
Hi All,

There have been a number of discussions over the past year regarding
how SA handles (NHibernate) transactions via the Transaction
attribute:

http://groups.google.com/group/sharp-architecture/browse_thread/thread/967b0e2628781bdb/8f19948b8ccf60fb?lnk=gst&q=Transaction+attribute#8f19948b8ccf60fb

http://groups.google.com/group/sharp-architecture/browse_thread/thread/696fe7bfc839fd9a/c0d99602425f8ce5?lnk=gst&q=Transaction+attribute#c0d99602425f8ce5

http://groups.google.com/group/sharp-architecture/browse_thread/thread/6eb327de688c2b66/e11b6f15decd85db?lnk=gst&q=Transaction+attribute#e11b6f15decd85db


I'd like to revisit this topic, and hopefully come to a conclusion
about the current best practices.

I'd especially like to put things in perspective with Tom's SA Contrib
Transaction and UnitOfWork Attributes:

http://wiki.sharparchitecture.net/SharpArchContrib.ashx

http://groups.google.com/group/sharp-architecture/browse_thread/thread/6ab3549c0b65a2e9/162c5405a456dca2?lnk=gst&q=Transaction+attribute#162c5405a456dca2


I am more than willing to turn our results into a Wiki page, so please
contribute as much as you can!

To frame the discussion, here are some points that would really help
me in clarifying the setup:


1) How does the SA Contrib Transaction Attribute relate to the regular
SA Transaction Attribute?

Can you use them together? For example, decorate the Controller action
method with an SA Transaction Attribute, and then decorate the Domain
Services (or Application Services) that the controller invokes with
the SA Contrib Transaction Attribute?


2) How does the SA Contrib Transaction Attribute relate to the SA
Contrib UnitOfWork Attribute?

The documentation seems to be conflicting here:

"Transaction PostSharp Attribute (Supports NHibernate or
System.Transaction. Works With ASP.NET, WCF, Windows GUI and Windows
Service Applications)"
http://wiki.sharparchitecture.net/SharpArchContrib.ashx

"You should use UnitOfWork in all Windows applications."
http://wiki.sharparchitecture.net/ContribUnitOfWork.ashx

Can the SA Contrib Transaction Attribute be used in a non-web
application?


3) Where should transaction management be placed? What layer is it a
concern of?

I've seen two general camps:

3a - Handle transactions in the Web.Controllers level with the SA
Transaction Attribute

3b - Handle transactions in the DomainServices or ApplicationServices
layers (presumably with the SA Contrib Transaction Attribute)

Is SA able to work with both types of setup?


4) How should exceptions be handled, in the context of transactions?


5) There are two types of transactions: NHibernate transactions, and
standard .NET transactions (Transaction.TransactionScope).

They are sometimes confused. Can the two be mixed? In what
circumstances should they be used together, if at all?


6) How can we utilize SA in a multi-client paradigm, in relation to
transactions?

This is the biggie for me, and likely crosses over all of the above
questions. Say I want my "core" app to be based of SA (Domain,
DomainServices, Infrastructure, etc), and then say I want to use this
"core" in both an SA-enabled website and another type of client (non-
SA enabled), like a Windows App or Service.

How can this be achieved? How can the "core" be implemented, so that
it can function in both "contexts"?


Since we are in DDD-land, a bit of terminology disclaiming is in
order:

Domain - POCO models
DomainServices - Domain level services/tasks that cross/mix (involve
more than one) entities (aggregate roots)
AppServices - Infrastructure level services. Services/processes like
"SendEmail" or "WriteFile" that involve interaction with external
resources


Thank you in advance for all your input.

Please note that my primary concern here is not for you to solve my
problems, but rather to facilitate a community process that will
hopefully end up with some solid guidelines/recommendations
documented.

Best regards,

Martin

Simone Busoli

unread,
Jan 7, 2010, 3:29:47 AM1/7/10
to sharp-arc...@googlegroups.com
That's a very interesting topic, I definitely would like to see a wiki page on it. I add to the mix this thread on the rhino-tools mailing list which talks a lot about transactions: http://groups.google.com/group/rhino-tools-dev/browse_thread/thread/57bff69e3b38ecc0

--
You received this message because you are subscribed to the Google Groups "S#arp Architecture" group.
To post to this group, send email to sharp-arc...@googlegroups.com.
To unsubscribe from this group, send email to sharp-architect...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sharp-architecture?hl=en.




Simone Busoli

unread,
Jan 7, 2010, 7:50:01 PM1/7/10
to sharp-arc...@googlegroups.com
I have created this wiki page, orphan at the moment: http://wiki.sharparchitecture.net/Transactions.ashx

martinaatmaa

unread,
Jan 8, 2010, 8:08:22 PM1/8/10
to S#arp Architecture
Hello Simone,
Thank you for the follow up.

I will revisit this topic this weekend, and update the wiki page you
created at that time.

Hopefully we'll be able to get some feedback on this.

Also, thank you for the link above. I'll give it a read tonight.


On Jan 7, 4:50 pm, Simone Busoli <simone.bus...@gmail.com> wrote:
> I have created this wiki page, orphan at the moment:http://wiki.sharparchitecture.net/Transactions.ashx
>

> On Thu, Jan 7, 2010 at 09:29, Simone Busoli <simone.bus...@gmail.com> wrote:
> > That's a very interesting topic, I definitely would like to see a wiki page
> > on it. I add to the mix this thread on the rhino-tools mailing list which
> > talks a lot about transactions:

> >http://groups.google.com/group/rhino-tools-dev/browse_thread/thread/5...


>
> > On Thu, Jan 7, 2010 at 03:30, Martin S <martinaat...@gmail.com> wrote:
>
> >> Hi All,
>
> >> There have been a number of discussions over the past year regarding
> >> how SA handles (NHibernate) transactions via the Transaction
> >> attribute:
>

> >>http://groups.google.com/group/sharp-architecture/browse_thread/threa...
>
> >>http://groups.google.com/group/sharp-architecture/browse_thread/threa...
>
> >>http://groups.google.com/group/sharp-architecture/browse_thread/threa...


>
> >> I'd like to revisit this topic, and hopefully come to a conclusion
> >> about the current best practices.
>
> >> I'd especially like to put things in perspective with Tom's SA Contrib
> >> Transaction and UnitOfWork Attributes:
>
> >>http://wiki.sharparchitecture.net/SharpArchContrib.ashx
>

> >>http://groups.google.com/group/sharp-architecture/browse_thread/threa...

> >> sharp-architect...@googlegroups.com<sharp-architecture%2Bunsu...@googlegroups.com>

Chris Nicola

unread,
Jan 18, 2010, 4:14:01 PM1/18/10
to S#arp Architecture
This is definitely something that needs to be discussed. As far as I
can tell the current Contrib and UnitOfWork pages are out of date
since it suggests that PostSharp is required and Contrib now appears
to use Castle Interceptors for AOP-like behavior.

I recently tried to use the UnitOfWork attribute in a project and
could not get it to work, transactions were not being opened or
committed and I ended up having to abandon using it. I have not yet
had time to review the SAContrib code to determine what I might be
doing wrong, but I plan to spend some time doing that this week.

On a somewhat related note, I also think that UnitOfWork and non-web-
session based session management is the sort of functionality that
should be considered for part of the core not just in Contrib, the
reasons I beleive that is another discussion altogether.

Chris

> > >> "You should useUnitOfWorkin all Windows applications."

Alec Whittington

unread,
Jan 18, 2010, 4:22:34 PM1/18/10
to sharp-arc...@googlegroups.com
Chris,
Please start a new thread and open up discussion on it. I would
like to hear your ideas on it.

Alec Whittington
Senior Consultant
Six Sigma Systems
602.320.1825

Scott Leckie

unread,
Jan 19, 2010, 1:09:46 AM1/19/10
to sharp-arc...@googlegroups.com
I agree with what Chris has written.

#Arch has been fantastic as a framework for 100% MVC projects, but the
rest of the world has difficulties getting to grips with the concepts,
especially with Forms / Services apps.

I note Alec's request that a new thread be opened, however I wanted to
register on this thread that those of us who are not 100% MVC (I'm
concentrating on SilverLight) have an uphill struggle that we want to
overcome.
Regards
Scott


On Mon, 18 Jan 2010 13:14:01 -0800 (PST), Chris Nicola
<chni...@gmail.com>
wrote:

Chris Nicola

unread,
Jan 19, 2010, 2:38:44 AM1/19/10
to sharp-arc...@googlegroups.com
I just wanted to update I did get UoW working with the new castle interceptors earlier today.  I will try to update the Wiki a little later if that's alright and I will start a new thread to discuss the merits of making UoW and the session-per-thread factory options available in #A.

Thanks,
Chris

To unsubscribe from this group, send email to sharp-architect...@googlegroups.com.

Chris Nicola

unread,
Jan 19, 2010, 12:37:24 PM1/19/10
to S#arp Architecture
One more thing, for some reason when using SAContrib and UoW you can't
get any output from show_sql=true. I am guessing this has something
to do with the logging interceptors and such, but I would like to hear
it explained. I have tried to figure it out from reading the SAC code
but so far no luck. Does anyone who worked on this understand this
behavior (and understand how to change it for testing?).

Thanks,
Chris

On Jan 18, 11:38 pm, Chris Nicola <chnic...@gmail.com> wrote:
> I just wanted to update I did get UoW working with the new castle
> interceptors earlier today.  I will try to update the Wiki a little later if
> that's alright and I will start a new thread to discuss the merits of making
> UoW and the session-per-thread factory options available in #A.
>
> Thanks,
> Chris
>

> On Mon, Jan 18, 2010 at 10:09 PM, Scott Leckie <scott.lec...@kwolo.com>wrote:
>
> > I agree with what Chris has written.
>
> > #Arch has been fantastic as a framework for 100% MVC projects, but the
> > rest of the world has difficulties getting to grips with the concepts,
> > especially with Forms / Services apps.
>
> > I note Alec's request that a new thread be opened, however I wanted to
> > register on this thread that those of us who are not 100% MVC (I'm
> > concentrating on SilverLight) have an uphill struggle that we want to
> > overcome.
> > Regards
> >  Scott
>
> > On Mon, 18 Jan 2010 13:14:01 -0800 (PST), Chris Nicola

> > <chnic...@gmail.com>

> > <sharp-architecture%2Bunsu...@googlegroups.com<sharp-architecture%252Buns...@googlegroups.com>

Chris Nicola

unread,
Jan 20, 2010, 1:21:51 PM1/20/10
to S#arp Architecture
Ok I think I have updated the Wiki entries correctly,  I have changed the instructions to match what I am doing which is working for me.  My apologies if anything is wrong. 

To unsubscribe from this group, send email to sharp-architect...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages