Hi!

Catching all exceptions will make the transaction try to commit. Could you
send a small .sln with a repro?

You're kind of eating the exceptions in a lot of places... Have you tried
letting the exception bubble out of the action instead, using a
[HandleError] page?

Regards,
Henrik

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Jan Limpens
Sent: den 10 juni 2009 15:06
To: Castle Project Users
Subject: Troubles with Automatic Transaction Facility (or something
completely different)


Hello,

I was having difficulties with that Facility, so before I dive into what
could be possibly wrong, I would like to share my code and hope somebody
spots an error right on, to save me some time debugging...

The trouble is, that if an exception (maybe a specific exception, but I am
not sure) is thrown withing the transaction, the transaction stays open with
a lock on the tables and it takes until sql server recycles for these tables
become responsible again.

The action method is pretty long, so I'll try to reduce it here and put the
original code @ http://pastebin.com/m3144a7e4.

        [Transactional]
        [Filter(ExecuteWhen.BeforeAction, typeof(AuthenticationFilter))]
        [Filter(ExecuteWhen.BeforeAction, typeof(RequiresFullCartFilter))]
        [SecureChannelFilter(true)]
        public class CheckOutController : BaseController
        {
                [AccessibleThrough(Verb.Post)]
                [Transaction(TransactionMode.Requires)]
                [return: JSONReturnBinder]
                public virtual PlaceOrderViewData PlaceOrder(
                        [DataBind("viewData.TempOrder")] Order tempOrder,
                        string selectedFreightOption,
                        [DataBind("viewData.Card")] CreditCardDTO
creditCardDTO,
                        [DataBind("viewData.Address")] AddressDTO
addressDTO,
                        string bankPaymentOption,
                        string billingAddress,
                        string selectedPaymentOption,
                        Boolean useFreightAsBillingAddress)
                {
// work, work, work
// I do a million things to construct an correct order out of the given
params. all this works, so I cut it out here // but then I try to send an
email....
try // in a try!
                        {
// XXXXXXX
sendOrderConfirmationMail(candidateOrder);
// some config error (an iis smtp pickup path that did not exist on the
server) caused this to fail // iis continued responsive // but all the
tables that were opened in the transaction are locked now because the
transaction is never committed // XXXXXXX
                        }
                        catch (Exception ex)
                        {
// I have this nowhere in my logs, so my guess is, the http request stops
here and is killed after a period of time, // at the browser level I never
received an answer. Only subsequent calls give me ado timeout exceptions.
                                Logger.Warn("Could not send order
confirmation mail.", ex.GetInnermostException());
                                return new
PlaceOrderViewData(ActionResult.Success,
ExternalMessageFactory.Checkout.OkButCouldNotSendMail, url);
                        }

                        return new PlaceOrderViewData(ActionResult.Success,
"", url);
                }
        }

Now correcting that config also "fixed" the error, but I am still kind of
spooked that this is possible at all. How can I be certain that some
exception at a completely different place won't leave my transactions open,
rendering the whole site useless?

Please mind, I am not blaming any component or author in particular,
everything might work as expected and I might be doing everything wrong. But
help and hints would be thankfully accepted.

-- Jan


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to