Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows service / WCF and threading, beginners question
    primarykey
    data
    text
    <p>We have a web service that sends requests to a windows service which hosts a WCF service for processing.</p> <p>The interface is simple:</p> <pre><code>namespace MyApp { [ServiceContract] public interface IMyApp { [OperationContract] string DoSomething(string xml); } [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] class MyAppWcf : IMyApp { public string DoSomething(string xml) { Customer customer = GlobalObject.GetCustomer(xml); //millisecs return customer.DoSomething(xml); //Takes 5-10 seconds } } } </code></pre> <p>GlobalObject is instantiated on the WindowsService.OnStart() and contains all the static data the customer objects need. The interface DoSomething() will be called up to ca. 30 different clients.</p> <p>Questions:<br /> 1. What is the default threading behaviour now? Will each call have to wait until the last one is finished?<br /> 2. What effect will changing InstanceContextMode?<br /></p> <p><strong>REAL</strong> question:<br /> There are up to 1000 customer objects, 2 different customer objects can be called in parallel, but the same one cannot. e.g.<br /> DoSomething("Customer 1"); => Goes ahead. Answer in 10 seconds<br /> DoSomething("Customer 2"); => Goes ahead in parallel with the above call.<br /> DoSomething("Customer 2"); => Will wait for last call of DoSomething("Customer 2") to finish<br /></p> <p>What should my service behavior settings be and do I have to implement a lock mechanism to prevent the same object being processed more than once in parallel?</p> <p>Thanks.</p> <p>Edit 2: GlobalObject.GetCustomer() just retrieves the customer mentioned in the XML from a dictionary.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload