سؤال

We are using declarative spring transaction attribute for database integrity. Some of our code call webservice which do bunch of stuffs in sharepoint. The problem is when webservices take longer time users get deadlock from spring which is holding up backend.

If I make a new thread inside a function which has spring transaction declarative attribute will that be ignored from spring?

[Transaction(TransactionPropagation.Required, ReadOnly = false)]
    public void UploadPDFManual(/*parameters*/)
    {
       //DO some data base related things

        if (revisionPDFBytes != null)
        {
          //my sharepoint call which calls webservice
           Task.Factory.StartNew(() => DocumentRepositoryUtil.CreateSharepointDocument(docInfo)); // I draw a new thread from ASPNET worker thread pool.
        }
    }

Anything other options I should go for?

هل كانت مفيدة؟

المحلول

You don't need doing it in a transaction. Transaction makes a database save an object properly. That's it. All other stuff must be done after the transaction commit. In Java, you can make it with Spring's transaction synchronization or JMS. Take a look at the accepted answer over here.

More useful info specific for .NET (see 17.8).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top