none
Counting user request in Service Contract RRS feed

  • Question

  • I am developing a WCF service that has to process only one user request at a time. Other request has to be queued up and if the queue gets big then then other request are stored in the database and users are notified accordingly. I was able to get user queue by implementing service throttling in WCF but users gets request timed out error when the queue is long. For request throttling I used WCF service throttling on service contract 2.

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single)]

    But for Service Contract 1, I have implemented

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Multiple)]

    I tried counting the pending request from WCF throttling service, but it seems there is no such method that gives current queue list in WCF.

    1. Is there any method that can count the queue list in another service contract.
    2. Do I have to change my design to implement this flow in WCF service.


    Saugat K.C.

    Monday, June 8, 2015 2:42 AM

Answers

  • Hi Saugat,

    In my opinion is that you can create different endpoints.One for contract1 one for contract2. So you can design multiple request in service . you can use different implemented contracts for different endpoints, the different contracts may implement different operations. But since those contract are implement by one service, there is only one proxy generated, so that the client consume the service can create a client instance for all of the classes( generated with different contracts) in the generatedClient class. So, that means may be you should create different service to support different operations.  Below is a MSDN sample.

    #Multiple Contracts

    http://msdn.microsoft.com/en-us/library/ms751424.aspx

    I hope that will be helpful to you .

    Best Regards,

    Tracy Dj


    Friday, June 26, 2015 8:44 AM
    Moderator

All replies

  • Hi Saugat,
        As per this case, I have shared my ideas below :
    1. I suggest you to design multiple request at a time instead of single request in service contract2
         Click here to know more about WCF concurrency & throttling.

    2.because you can keep all  the client request into database or an arraylist

    3.then you can count the queue list  by using query in the same service contract2.

    Moreover you can refer this article which explains that WCF service - best way to accept requests from a client and do background work.

    Wednesday, June 10, 2015 7:54 AM
  • Thank you Edwin for your answer.

    I tried implementing this but the problem is that Service contract2 has a method that can operate one request at a time. When I do the background work, I think I may not be able to provide the direct file download as a response to the user.  


    Saugat K.C.

    Wednesday, June 10, 2015 10:23 AM
  • Hi Saugat,

    In my opinion is that you can create different endpoints.One for contract1 one for contract2. So you can design multiple request in service . you can use different implemented contracts for different endpoints, the different contracts may implement different operations. But since those contract are implement by one service, there is only one proxy generated, so that the client consume the service can create a client instance for all of the classes( generated with different contracts) in the generatedClient class. So, that means may be you should create different service to support different operations.  Below is a MSDN sample.

    #Multiple Contracts

    http://msdn.microsoft.com/en-us/library/ms751424.aspx

    I hope that will be helpful to you .

    Best Regards,

    Tracy Dj


    Friday, June 26, 2015 8:44 AM
    Moderator