WorkflowServiceHost, multiple services and the WorkflowRuntime<p align=left><font face=Arial size=2></font> </p> <p> </p> <p align=left>Hi,</p> <p align=left> </p> <p align=left>I am hosting the workflow runtime in a windows form application to run a number of &quot;standard&quot; WF workflows. I now want to add a number of WorkflowServices. I intend to create a WorkflowServiceHost to host my services.</p> <p align=left> </p> <p align=left>I noticed a post from Tom Lake that each WorkflowServiceHost can only host a single workflow service (<a title="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2233752&amp;SiteID=1" href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2233752&amp;SiteID=1">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2233752&amp;SiteID=1</a>). </p> <p align=left> </p> <p align=left>Also, I observe that it is posible to get a reference to the runtime being used by the service host by writing code like:</p> <p align=left> </p><font color="#2b91af" size=2> <p>WorkflowRuntimeBehavior</font><font size=2> workflowRuntimeBehaviour = host.Description.Behaviors.Find&lt;</font><font color="#2b91af" size=2>WorkflowRuntimeBehavior</font><font size=2>&gt;();</p> <p></font><font color="#2b91af" size=2>WorkflowRuntime</font><font size=2> rt = workflowRuntimeBehaviour.WorkflowRuntime;</p> <p> </p> <p align=left>My question is - how many runtimes must I have? Can my standard workflows and each hosted service all share the same undelying runtime or do I need to spin up and configure a seperate runtime in each case?</p> <p align=left> </p> <p align=left>Also, could anyone point me at a good code sample for programatically hosting multiple services.</p> <p align=left> </p> <p align=left>Thanks</p> <p align=left> </p> <p align=left>Adrian</p> <p align=left></font> </p>© 2009 Microsoft Corporation. All rights reserved.Tue, 06 Jan 2009 19:39:06 Z26e793b0-a707-4ebb-9058-359386b60cd2http://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#26e793b0-a707-4ebb-9058-359386b60cd2http://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#26e793b0-a707-4ebb-9058-359386b60cd2Dr Adrian Colquhounhttp://social.msdn.microsoft.com/Profile/en-US/?user=Dr%20Adrian%20ColquhounWorkflowServiceHost, multiple services and the WorkflowRuntime<p align=left><font face=Arial size=2></font> </p> <p> </p> <p align=left>Hi,</p> <p align=left> </p> <p align=left>I am hosting the workflow runtime in a windows form application to run a number of &quot;standard&quot; WF workflows. I now want to add a number of WorkflowServices. I intend to create a WorkflowServiceHost to host my services.</p> <p align=left> </p> <p align=left>I noticed a post from Tom Lake that each WorkflowServiceHost can only host a single workflow service (<a title="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2233752&amp;SiteID=1" href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2233752&amp;SiteID=1">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2233752&amp;SiteID=1</a>). </p> <p align=left> </p> <p align=left>Also, I observe that it is posible to get a reference to the runtime being used by the service host by writing code like:</p> <p align=left> </p><font color="#2b91af" size=2> <p>WorkflowRuntimeBehavior</font><font size=2> workflowRuntimeBehaviour = host.Description.Behaviors.Find&lt;</font><font color="#2b91af" size=2>WorkflowRuntimeBehavior</font><font size=2>&gt;();</p> <p></font><font color="#2b91af" size=2>WorkflowRuntime</font><font size=2> rt = workflowRuntimeBehaviour.WorkflowRuntime;</p> <p> </p> <p align=left>My question is - how many runtimes must I have? Can my standard workflows and each hosted service all share the same undelying runtime or do I need to spin up and configure a seperate runtime in each case?</p> <p align=left> </p> <p align=left>Also, could anyone point me at a good code sample for programatically hosting multiple services.</p> <p align=left> </p> <p align=left>Thanks</p> <p align=left> </p> <p align=left>Adrian</p> <p align=left></font> </p>Wed, 20 Feb 2008 13:52:00 Z2008-02-20T13:52:00Zhttp://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#13f09a01-1c9d-4c37-8af6-a21bdd5798d1http://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#13f09a01-1c9d-4c37-8af6-a21bdd5798d1Dinesh Ravva - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Dinesh%20Ravva%20-%20MSFTWorkflowServiceHost, multiple services and the WorkflowRuntime<p align=left>Multiple services cannot share a runtime. Each service has its own workflow runtime. </p> <p align=left> </p> <p align=left>You could create a service for a workflow by creating and opening a workflowservicehost for the workflow type. The workflowservicehost takes care of creating the workflowruntime internally.</p>Fri, 22 Feb 2008 07:10:51 Z2008-02-22T07:10:51Zhttp://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#b2e372e2-6ce8-4ab1-9b94-1ec020fcefdchttp://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#b2e372e2-6ce8-4ab1-9b94-1ec020fcefdcDr Adrian Colquhounhttp://social.msdn.microsoft.com/Profile/en-US/?user=Dr%20Adrian%20ColquhounWorkflowServiceHost, multiple services and the WorkflowRuntime<p align=left><font face=Arial size=2></font> </p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'">At first glance this seems a bit of an odd design?</span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'"> </span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'">We don’t have a one workflow - one workflow runtime design paradigm in .NET 3.0. In a real world scenario where we plan to deploy many service workflows we would surely have an unmanageable number of runtimes. </span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'"> </span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'">Also, how would we make use of things like custom runtime services and host to workflow communication mechanisms like external data exchange services in such a scenario? Could we share runtime service instances, custom tracking channels etc between the multiple runtime instances? </span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'"> </span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'">Presumably the only viable inter workflow communication option in this architecture is via send and receive activities to other service enabled endpoints?</span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'"> </span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'">Or alternatively, is the workflow runtime sufficiently lightweight that in the brave new &quot;service orientated&quot; - one workflow service - one runtime is exactly the way to go - does anyone else have any views ?</span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'"> </span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'">Adrian</span></p> <p> </p>Fri, 22 Feb 2008 09:19:07 Z2008-02-22T09:19:07Zhttp://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#9945c8b0-bac1-452b-90ea-0c0a4c7df56bhttp://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#9945c8b0-bac1-452b-90ea-0c0a4c7df56bDr Adrian Colquhounhttp://social.msdn.microsoft.com/Profile/en-US/?user=Dr%20Adrian%20ColquhounWorkflowServiceHost, multiple services and the WorkflowRuntime<p align=left><font face=Arial size=2>bump</font></p>Wed, 05 Mar 2008 10:23:09 Z2008-03-05T10:23:09Zhttp://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#90261e00-4935-402e-8c42-a9bb9c4ae15bhttp://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#90261e00-4935-402e-8c42-a9bb9c4ae15bjasonshonedudedudehttp://social.msdn.microsoft.com/Profile/en-US/?user=jasonshonedudedudeWorkflowServiceHost, multiple services and the WorkflowRuntime<p align=left><font face=Arial size=2>We are at this point also, cannot seem to add another Workflow to the same runtime.  Did you make any progress on this?</font></p>Thu, 03 Apr 2008 01:59:15 Z2008-04-03T01:59:15Zhttp://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#e7ec1b61-e032-4dc0-82b2-0f751c806641http://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#e7ec1b61-e032-4dc0-82b2-0f751c806641Dr Adrian Colquhounhttp://social.msdn.microsoft.com/Profile/en-US/?user=Dr%20Adrian%20ColquhounWorkflowServiceHost, multiple services and the WorkflowRuntime<p><span style="font-size:10pt;font-family:'Arial','sans-serif'">None</span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'"> </span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'">It seems a fairly fundamental (and limiting) design decision if Dinesh is correct (I'd have to assume he is given his closeness to the team). I went back to using WCF/WF 3.0 allowing me to manage the runtime myself (but then requiring me to do more work!). I tried bumping the thread to see if I could get some more insight and comments but no one else responded.</span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'"> </span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'">Cheers</span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'"> </span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'">Adrian</span></p> <p class=MsoNormal style="margin:0cm 0cm 10pt"><font face=Calibri size=3> </font></p>Fri, 04 Apr 2008 08:41:27 Z2008-04-04T08:41:27Zhttp://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#40939e4e-fddf-4226-8ff5-e1d84b5b500ehttp://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#40939e4e-fddf-4226-8ff5-e1d84b5b500eMatthew D Erwinhttp://social.msdn.microsoft.com/Profile/en-US/?user=Matthew%20D%20ErwinWorkflowServiceHost, multiple services and the WorkflowRuntime<p align=left><font face=Arial>Anything happen on this in the last 6 months? I'm playing around with custom Factories to see if there are some possibilities there but this is disturbing.</font></p> <p align=left> </p> <p align=left>I had a few thoughts on how Microsoft intended for people to deal with this problem without having to manually write all the bridge code. It appears that the solution is to write a custom WorkflowServiceHost and WorkflowServiceHostFactory. By doing so you can control when/if a new WorkflowRuntime is created so you could have a single common runtime regardless of the # of workflows hosted.</p> <p align=left> </p> <p align=left>Secondarily, to deal with the terrible annoyance of having a single method per .SVC you can put numerous &quot;receive&quot; activities into a single workflow to provide all the methods needed for a service and have that act like a router (Facade pattern). I haven't played around with that idea too much but anything seems better than this one-to-one business.</p> <p align=left> </p> <p align=left> </p>Fri, 21 Nov 2008 06:30:47 Z2008-11-21T06:30:47Zhttp://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#434a7266-f5f5-47a5-8e74-a00bf634e5e9http://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#434a7266-f5f5-47a5-8e74-a00bf634e5e9Dr Adrian Colquhounhttp://social.msdn.microsoft.com/Profile/en-US/?user=Dr%20Adrian%20ColquhounWorkflowServiceHost, multiple services and the WorkflowRuntime<p>Matthew</p> <p align=left> </p> <p align=left>I gave up and hosted it myself. The lack of replies on the thread suggests to me that not many people actually use this functionality in anger.</p> <p align=left> </p> <p align=left>One observation from comments made at the PDC is that WF 4.0 is a rewrite from the ground up so perhaps we might hope that this will change next year? </p> <p align=left> </p> <p align=left>Cheers</p> <p align=left> </p> <p align=left>Adrian</p> <p align=left><font face=Arial size=2></font> </p>Fri, 21 Nov 2008 10:40:50 Z2008-11-21T10:40:50Zhttp://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#9e418a87-f1cb-48ad-9451-ea8a4d6b7ceehttp://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/26e793b0-a707-4ebb-9058-359386b60cd2#9e418a87-f1cb-48ad-9451-ea8a4d6b7ceedkehringhttp://social.msdn.microsoft.com/Profile/en-US/?user=dkehringWorkflowServiceHost, multiple services and the WorkflowRuntime Can you provide some insight into how you solved this problem? I'm facing the same issue. I've tried the &quot;router&quot; concept but unless I'm doing something wrong, it messes up persistence (the workflow never gets closed). I fear that this plumbing code will involve rudimentary work with queues and context management. By hosting it yourself, did you simply bypass anything related to 3.5?<br><br>Thanks.<br>Dave<br>Tue, 06 Jan 2009 17:50:57 Z2009-01-06T17:50:57Z