I have a BPM that I would like to split up into 4 threads so they can run simultaneously. Is this possible?
I would say it depends, are you writing your own logic? If so, I dont see why you couldnt run either separate threads or some logic in a parallel foreach if applicable. Just make sure you use the right context/record locking as neededâŚ
Iâm writing my own C# code in the BPM (not Visual Studio).
Iâm just looking for simple example code that shows the context and locking (if needed).
Imagine that for every PartDtl record Iâm creating 1 or more UD01 records.
Jason Woods
http://LinkedIn.com/in/jasoncwoods
I am thinking something like this - no warranties
using System.Threading;
using System.Threading.Tasks;
Parallel.ForEach(ttPartDtl, (PDtl) =>
{
using (var scope = IceContext.CreateDefaultTransactionScope())
{
//your UD01 BO and creation code here...
//Db.Validate();
scope.Complete();
}
}
);
I experimented with multi-thread within the product configurator, and found it was possible, but it was a challenge. One thought on the locking and instead of writing your own multi-thred⌠you could create this sort of like MRP works, splitting up the records into 4 separate sets of parts, and then launching off 4 asynchronous processes⌠this would then âsimplyâ process 1/4th of the data in each async task you release, but all in parallel.
One reminder - SQL Server does NOT allow threading on the same connection. This means standing up new connections in a suppressed transaction - so no roll backs. There are a LOT of implications when you start digging into multiple threads so be MASSIVELY careful. The basis of a lot of server code - in general not just E10 or .NET - is single threaded and for a reason. e.g. - nodejs is a single thread.
Adding on to this⌠a common (and safer) practice is to spin up multiple âclientsâ that each do a separate âserver callâ. Especially if you span companies or other âsession contextâ type work, it is a safer (and faster) execution - no data locking, etc since each server call is isolated already. We actually do this in MRP for example.
And this is why I like to ask open ended questions.
âShould I play with this flame thrower and TNT?â
Thanks Bart for steering me!
Jason Woods
Owner | Jason Woods Consulting
jason@jasonwoods.me | Cell: 360.903.4893