Note to self on workflow 4, context correlation and service parameters
Sorry if this is a bit too vague, but I wanted to make note of this, before I forget, and figured – if it might help someone – might as well blog it as is -
I’ve set-up a workflow with a context correlation scenario – in my scenario I used a pick activity, but I don’t know if that’s significant, where the trigger of one Pick branch has a ‘receive and send reply’ template in which the receive activity is set to create a new instance (CanCreateInstance=true) and the trigger of another pick branch has a receive activity configured to follow the correlation (CanCreateInstance=false).
When I ran my scenario the call to the first service’s operation, the one creating the instance, worked fine, but when calling the second operation, which was intended to enter into the correlated receive, I got the following error on the client -
“The execution of an InstancePersistenceCommand was interrupted because the instance key 'd7c81b72-21a3-cd67-e7178a39e708b766' was not associated to an instance. This can occur because the instance or key has been cleaned up, or because the key is invalid. The key may be invalid if the message it was generated from was sent at the wrong time or contained incorrect correlation data.”
Took some trial and error, and at the moment it doesn’t quite make sense to me, but it turns out something seemingly completely unrelated seem to be the cause of this - initially, I forgot to assign the parameters of the second receive shape (the one following the correlation) to local variables.
If I do that, the problem goes away (!), remove the local variables from the UI, and the error is back. weird!
I’m not quite sure yet why this would have that effect, but it clearly did, I tried this several times and it happened every time.
I’ll keep digging, but for the time being – was worth making a note of that…..