February 27, 2012 at 14:34
filed under Dynamics AX
Tagged 2012, Batch, Dynamics AX, Performance, Services, SysOperation, Technical conference
Hi all!
When I was at the technical conference in Nice last year, I attended the session about performance (BRK224), and during a demo, something interesting was shown: how to add one BOF service as a runtime task to another BOF service in batch.
You can watch the session recording here, the code is shown about 44 minutes, 50 seconds in.
If you are unfamiliar with runtime tasks and how to use them, read my post about batch multithreading for an explanation. The basic principle stays the same, but in the example below, we will be using the Business Operation Framework (aka BOF, aka SysOperation) instead of RunBaseBatch.
The first thing you’ll need to do, is create 2 BOF services, one that will create the runtime tasks, and one that will represent the runtime task. If you don’t know how to do that, read this post: SysOperation Introduction. You can download the xpo file for the following example below.
This service will be our runtime task. It’s a regular BOF service, nothing special about it. In my example, the service operation contains some testing code so we can see if our service is working:
The data contract for this service has one member:
This is the service that will create the runtime tasks. Starting for a regular BOF service, make sure that the service class extends SysOperationServiceBase. This enables us to call the isExecutingInBatch() method later on.
The service operation that creates the runtime tasks looks like this:
For this demo, I created a loop that creates 5 runtime tasks.
When you execute this in batch, you can check the batch task history for the batch to see the tasks that have been created.

You can click the Parameters button to verify if the correct values were used to execute the task.
You can download the XPO here.
Links
Another example can be found on Kenny Saelen’s blog: Business Operation Framework and multi-threading
Related posts
AX2012: SysOperation part 1: Data Contracts and Service Operations
AX2012: SysOperation part 2: SysOperationServiceController
AX2012: SysOperation part 3: SysOperationAutomaticUIBuilder
AX2009: Batch multithreading (RunBaseBatch)
no comments
RSS / trackback