Welcome Guest, you are in: Login

Castle Project


Navigation (Windsor)

Search the wiki


This documentation is a work in progress.

Let us know if some information is not clear, inaccurate or missing. Also feel free to update the wiki yourself.

Automatic Transaction Management Facility

Modified on 2010/05/18 09:08 by Krzysztof Ko┼║mic Categorized as Facilities


This facility manages the creation of Transactions and the associated commit or rollback, depending on whether the method throws an exception or not.

Transactions are logical. It is up the other integration to be transaction aware and enlist its resources on it.

Quick start

This facility usually works together with others facilities, as it requires an implementation of ITransactionManager. Currently the ActiveRecord Integration Facility and NHibernate facility implement the ITransactionManager.

Defining transaction behavior on components

You can use attributes or the configuration file to associate transaction information with your components.

Using attributes

using Castle.Services.Transaction;

public class BusinessClass
   public void Load(int id)

   // note the "virtual" 
   public virtual void Save(Data data)

Using configuration

         type="Namespace.BusinessClass, AssemblyName"
            <method name="Save" />
            <method name="Create" />

Class methods must be virtual

If you are registering the component without an interface as a service you must make the methods virtual in order to being intercepted. Please refer to DynamicProxy documentation for more information about it.


  • NotSupported: Transaction context will be created but no transaction is started
  • Requires: Transaction context will be created if not present
  • RequiresNew: A new transaction context will be created (not supported at the moment)
  • Supported: An existing appropriate transaction context will be joined if present (not supported at the moment)

Required Assemblies

  • Castle.Facilities.AutomaticTransactionManagement.dll
  • Castle.Services.Transactions.dll
  • Castle.Core.dll

ScrewTurn Wiki version Some of the icons created by FamFamFam.