Dynamics AX - Thread Development vs. Batch runtime task
Recently, in the past months, I talked about in a few post using Threads in your X++ code, to help with adding parrellel processing to long running processes.
Dynamics AX 2009 - X++ Thread Development
Dynamics AX Threads - More details
There is for sure, a specific time and place to use Threads, however what about in Batch? What if I want to take the work I am doing with threads, and actually run that now in a batch processing mode?
Bottom line.: It will not work!
Threads, currently, can't be spawned from within a batch executing task. The design behind batch framework is geared around taking and using the BatchHeader class, and the runtime task framework, to create batch task.
If you do this, you will see these task execute under the same context as threads, being that of a "worker" user type.
So as I said, Thread development has it's time and place, and that does not include Batch related execution. Threads are best for user processes, where the process always involves a user kicking off that said process. If batch based execution is needed, then taking the example of found in the Journal Batch Processing whitepaper, you can take and allow for parrellel execution of code, with batch task being created, vs. threads being spawned.
There are other good examples of this actually, including the Inside Dynamics AX 2009 book, which covers this topic as well.
So with this, we have two ways to achieve parrellel processing, and depending on the desired nature of the process, will drive you to which method. To batch, or not to batch? For this, that is the driving question!
That's all for now, but check back soon, as more to come!
"Visit the Dynamics AX Community Page today!"
Dynamics AX 2009 - X++ Thread Development
Dynamics AX Threads - More details
There is for sure, a specific time and place to use Threads, however what about in Batch? What if I want to take the work I am doing with threads, and actually run that now in a batch processing mode?
Bottom line.: It will not work!
Threads, currently, can't be spawned from within a batch executing task. The design behind batch framework is geared around taking and using the BatchHeader class, and the runtime task framework, to create batch task.
If you do this, you will see these task execute under the same context as threads, being that of a "worker" user type.
So as I said, Thread development has it's time and place, and that does not include Batch related execution. Threads are best for user processes, where the process always involves a user kicking off that said process. If batch based execution is needed, then taking the example of found in the Journal Batch Processing whitepaper, you can take and allow for parrellel execution of code, with batch task being created, vs. threads being spawned.
There are other good examples of this actually, including the Inside Dynamics AX 2009 book, which covers this topic as well.
So with this, we have two ways to achieve parrellel processing, and depending on the desired nature of the process, will drive you to which method. To batch, or not to batch? For this, that is the driving question!
That's all for now, but check back soon, as more to come!
Labels: Batch Framework, Batch Task, BatchHeader, Dynamics AX 2009, Inside Dynamics AX, Microsoft, Thread Development, Threads, Whitepaper
0 Comments:
Post a Comment
<< Home