Hi everybody,
I couldn't find any documentation regarding parallel process step.
It seems like that context.Properties values are not persisted after the parallel steps, is that corrrect?
context.State instead works. Is there any drawbacks with it, or something I should pay attention to?
What's the difference between using context.Properties and context.State collections?
Thank you!
Fabrizio
Tags: parallel, process, properties
Hi Fabrizio. Each branch of the parallel process step receives its own copy of the context.Properties collection, and you are right that those values are not persisted after the parallel step. This was done so that we did not have to worry about or complicate the implementation with concurrency issues typical with sharing data across threads. The side-effect of this is that at the end of the branch execution, there's not really a good way of merging changes to context.Properties because two or more branches may have conflicts that prevent merging.
context.State is global data that is tied to the process itself, not to any particular process instance. It is backed by a ConcurrentDictionary, so it can be safely accessed by multiple threads. All executions of a process share the same context.State object.
I hope that this helps. Please let me know if you have any additional questions.
great, thanks for the explanation.
Then I understand it's not a good strategy to use context.State.. I could end up with wrong data being shared my multiple instances.
What would be a way to save values retrieved within a branch? Do we have a kind of instance id to use as key to a collection saved in the context.State?
Any other suggestions?
Thank you
F.
Actually, I need to correct my previous answer. I was just looking at the source code. At the end of the branch execution, we do merge the context.Properties for the branch into the main process branch. What we do is that we add the property in the format "<branch-name>.<property-name>". So if you create a property in context.Properties named "accountId" in a branch named "Branch1", then you can retrieve it later using the key "Branch1.accountId".
We only merge the properties that either do not exist in the main context.Properties for the process, or whose values differ from what's in context.Properties.
Yes! it works,
thank you for the quick answer and explanation
Neuron ESB Product Support Forums and Communities
© 2024 Created by Neuron Admin. Powered by