E10 BPM Threading

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 :wink:

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

www.linkedin.com/in/jasoncwoods

http://jasonwoods.me

1 Like