Beantwortet choice with timeout

  • Montag, 22. August 2011 15:01
     
     

    Hi guys,

    I have a WCF service that sends request via CCR iterators to SQL to run stored procedures.

    Sometimes, the stored procs takes a while to return and we'd like to exit from the iterator after a specified timeout.

    What's the best way to implement this


    Even though the existence of God cannot be determined through reason, a person should wager as though God exists, because living life accordingly has everything to gain, and nothing to lose - Pascal Blaise

Alle Antworten

  • Mittwoch, 24. August 2011 17:04
     
     Beantwortet
  • Mittwoch, 24. August 2011 18:11
    Moderator
     
     Beantwortet

    This depends on exactly how you're using CCR to execute the stored proc, but one of the important considerations when introducing an 'out-of-band' timeout in CCR is to correctly clean-up if a timeout does occur. There are two common patterns when wrapping async operations with CCR:

    1. Your async callback calls the EndXXX operation posting either the result of that call or an exception if thrown, to some PortSet<Result, Exception>.
    2. Your async callback is Port.Post and you are using the Port<IAsyncResult> pattern.

    You can combine either of these approaches with a timeout port in a choice, but if you use the second approach and the timeout handler *does* fire, within that handler you must reactivate the Receive handler on the Port<IAsyncResult> and call the EndXXX operation.

    Although the CCR timeout fires before the async operation completes, the async operation will complete at some point (even if you no longer care) and you must still call EndXXX, else risk leaking the resources associated with the async operation.

    Just out of interest, is there any reason why, for your particular case, SQL command timeouts can't be used directly?

  • Donnerstag, 25. August 2011 04:12
     
     

    Thanks a million guys.

    Can I call Sql Command Timeout on a command of type Stored Proc.

    I was made to believe it only works with command Texts.

     

     


    Even though the existence of God cannot be determined through reason, a person should wager as though God exists, because living life accordingly has everything to gain, and nothing to lose - Pascal Blaise