Asynchronous WCF Service Question

Discussion in 'ASP .Net Web Services' started by Vikas, Jun 8, 2008.

  1. Vikas

    Vikas Guest

    Hi
    I am using WCF Services exposed as REST URIs to be consumed by generic
    AJAX clients. All of my services need to be Async in nature.
    We have a typical n-layer architecture for our project wherein the
    Service Layer --> Business Layer and
    Business Layer --> Data Access Layer
    Data Access Layer --> LINQ --> DB

    The heaviest part of the processing will be fetching and sending
    updates to the database. As such this part needs to be made
    asynchronous.
    Earlier, we had thought that the service layer would simply accept the
    calls. It would then use ThreadPool.QueueUserWorkItem to spawn a
    secondary thread and move the calls to the Business Layer onwards to
    this secondary thread. For e.g.

    public IAsyncResult BeginGetData(params)
    {
    //Create an AsyncResult
    ThreadPool.QueueUserWorkItem(SomeCallback, AsyncResult)
    //Return AsyncResult
    }

    private void SomeCallback(object state)
    {
    //Call BUSINESS Layer which calls Data Access Layer and so on.
    }

    public string GetData(AsyncResult)
    {

    }
    But this defeats the purpose of Async operations since we end up using
    threads from the same thread pool as ASP.Net for the WCF services. A
    load test confirmed this too. The performance was worse than a
    synchronous WCF service call. An article I read on Async HTTP handlers
    mentioned the same.

    Do I need to split my Business Layer and Data Access Layer methods
    into Begin and End pairs too? Or is there a better way.

    Kindly let me know, what is the preferred way of handling this as I am
    sure that this would be a problem faced commonly.

    Thanks in advance
    Vikas Manghani
     
    Vikas, Jun 8, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Billy Zhang
    Replies:
    7
    Views:
    1,371
    Steven Cheng [MSFT]
    Jul 31, 2008
  2. Simon
    Replies:
    0
    Views:
    1,066
    Simon
    Oct 13, 2009
  3. Cindy Lee
    Replies:
    1
    Views:
    2,254
    Mr. Arnold
    Mar 19, 2010
  4. Curt K
    Replies:
    3
    Views:
    485
    John Saunders [MVP]
    Jun 15, 2007
  5. kellygreer1

    Web Service versus WCF Service (and Books)

    kellygreer1, Nov 8, 2007, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    179
    Andrew Faust
    Nov 9, 2007
Loading...

Share This Page