none
Multiple service contract inter-commnication RRS feed

  • Question

  • I am stuck in a problem that I cannot get out of it. I am designing and developing a system that has to process one request at a time, put other requests into the queue and if the queue gets more than 5, return invalid statement to user. I tried many options but could not get the result that I am looking for. The brief new system design that I plan to implement now is shown below: enter image description here

    My questions are:

    1. Is it possible to implement this kind of system design (calling one service contract from another)
    2. Is there any best approach to achieve this?

    I just have to create a system that has a bottle neck into it. But if the queue is too long, return some invalid statements. I have already created service contract 2 and 3 where contract 2 handles multiple request and contract 3 handles one request at a time. The basic problem with this approach will be, if the queue get long enough, the users may face time execution error since there will be no response from the server.


    Saugat K.C.

    Wednesday, June 10, 2015 3:52 AM

Answers

  • Hi Saugat,
       As far as I know,There's nothing built into WCF that would allow you to handle the message queuing explicitly,

    While your service could certainly process requests from MSMQ, the MSMQ listeners in WCF will pick and process messages as soon as possible; also you can't configure them to process messages at certain time interval

    One option if your delay between processing requests isn't very short, would be to use an intermediate queue to hold pending requests. That is, whatever sends the real requests writes them to a queue nobody is directly listening to (queue A), while your WCF service listens on a different queue (queue B). Then, have something else (could be as simple as a script run from task scheduler) that runs once every X seconds/minutes/whatever and moves just 1 message from queue A to queue B, thus triggering the actual WCF service to run.
    So You might be put your requests into a queue and then process one queue entry at a time.This approach might be to use an in-memory queue within your own service that calls the other once per entry and use some kind of locking. But this might need some careful thought to avoid bad deadlocks.

    Friday, June 12, 2015 9:42 AM

All replies

  • Hi Saugat,
       As far as I know,There's nothing built into WCF that would allow you to handle the message queuing explicitly,

    While your service could certainly process requests from MSMQ, the MSMQ listeners in WCF will pick and process messages as soon as possible; also you can't configure them to process messages at certain time interval

    One option if your delay between processing requests isn't very short, would be to use an intermediate queue to hold pending requests. That is, whatever sends the real requests writes them to a queue nobody is directly listening to (queue A), while your WCF service listens on a different queue (queue B). Then, have something else (could be as simple as a script run from task scheduler) that runs once every X seconds/minutes/whatever and moves just 1 message from queue A to queue B, thus triggering the actual WCF service to run.
    So You might be put your requests into a queue and then process one queue entry at a time.This approach might be to use an in-memory queue within your own service that calls the other once per entry and use some kind of locking. But this might need some careful thought to avoid bad deadlocks.

    Friday, June 12, 2015 9:42 AM
  • Is it possible to implement this kind of system design (calling one service contract from another)

    It seems to me that you should be using MSMQ behind the WCF service and dump things into a queue for processing. It also seems to me that a Business Logic Layer clsslib project  should be sitting behind the WCF service that the WCF service references, and the BLL should be making the decisions.

    Friday, June 12, 2015 1:42 PM