Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define multiple Receive activities within a single workflow service (WF4)

I have a workflow service (defined declaretively in a .xamlx file) that currently contains one Recieve activity. As you may know, services usually expose more than one operation. And that's what I would like to do with my service too. How do I add more operations to this service? Without WF, that's really easy. Just add as many methods as you wish and decorate them with OperationContract. Then the client can call any of the operations that service offers. In WF4, on the other hand, when I try to add another Recieve activity to the service, I can only add it either before or after an existing activiy. I thought I might use the Pick activity to accomplish this, but I'm just guessing. Is this how I do it? Or should I add another workflow service and add the Receive activity to it? (doesn't sound like a good solution at all). Or perhaps there is a right way to accomplish this?

P.S As you can tell, I'm totally new to WF in general, and WF4 in particular.

Thanks, Avi

like image 463
Avi Shilon Avatar asked Dec 29 '22 00:12

Avi Shilon


1 Answers

Having a single Receive activity at the start of a workflow is not uncommon, after all there is usually a single event that starts a workflow. And once started it can wait for other messages to arrive. However there is no reason not to have a workflow listen for multiple different at the same time and, as you mentioned, a Pick activity is the way to go. Just drop a Pick on the design surface, add as many PickBrache with Receive activities as you like and you are good to go.

like image 161
Maurice Avatar answered Feb 23 '23 01:02

Maurice