Tuesday, September 17, 2013

Switching a ReplicatorActivity from ‘Sequence’ to ‘Parallel’

Had a scenario in a FIM workflow activity where I needed to change the behaviour from ‘sequential’ to ‘parallel’.  Simple enough, it’s just a property on the ReplicatorActivity that I set and the framework magically handles the rest, right?

Well it compiled and ran just fine, but the results were not was you’d expect.  This behaviour is well documented I guess but I was a little surprised at how much work it took to make it work.  The blog post here –> ‘Using the ReplicatorActivity in Parallel mode’ was a really good explanation and I did try to follow the guidance but in the end chose to follow the common wisdom of “the ReplicatorActivity can only be used in parallel mode with a custom activity”.  That common wisdom may be incorrect, but the code became a lot cleaner when I just bit the bullet and created that custom activity.

Readers of this blog may be marveling at a post where I neglect to mention PowerShell.  This is not that post.  I’m impressed at PowerShell’s ability to dumb this stuff down.  Workflow is a big feature in PowerShell 3, and the awesome part is how easy they made it:

New-Workflow –MakeItEasy: Authoring Workflows using PowerShell Extended Syntax

Workflow in FIM can be challenging to a below-average developer, but workflow in PowerShell can be as simple as using the ‘workflow’ keyword, or adding the ‘-parallel’ parameter to a ‘foreach’ statement.  Very cool.

No comments: