I have some workflow 4 services with OperationContextScope activity wrapped around the Receive/SendReplyToReceive pairs to get access to the OperationContext.Current object. The OperationContextScope activity is from the WF Security Pack CTP at http://wf.codeplex.com/releases/view/48114. I use Windows Server AppFabric for hosting.
Now, I've just discovered that OperationContextScope establishes a no-persist zone. Since OperationContextScope is used by wrapping a sequence starting with a Receive and ending with a SendReplyToReceive, no persistance can take place at the time the workflow reaches the Receive.
This causes a problem since I have set up AppFabric to persist immediately when the workflow becomes idle, and it becomes idle when it reaches a Receive activity. The persist does not take place. I have also configured AppFabric to unload idle activities after 60 seconds. So after 60 seconds of idling at the Receive, my instance is wiped from memory, but, without getting persisted first.
As far as I understand, the instance will then resume from its last persistance point and continue until it reaches the same Receive as before. And again, it will fail to persist, unload after 60 seconds, resume from last persisted point, and so on.
To me, it seems like the OperationContextScope activity has a design flaw as it prevents automatic persistance and unloading of instances to happen as it should. Or am I using the activity the wrong way?