문제

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