Starting an originating task that invokes a synchronous interface

Why and when to perform this task

Originating tasks that invoke a synchronous interface include inline originating tasks in a microflow, stand-alone originating tasks in a microflow, and originating tasks that start, for example, a simple Java class.

This scenario creates an instance of a task template and passes some customer data. The task remains in the running state until the two-way operation returns. The result of the task, OrderNo, is returned to the caller.

Steps for this task

  1. Optional: List the task templates to find the name of the originating task you want to run.

    This step is optional if you already know the name of the task.

    TaskTemplate[] taskTemplates = task.queryTaskTemplates
    ("TASK_TEMPL.KIND=TASK_TEMPL.KIND.KIND_ORIGINATING",
     "TASK_TEMPL.NAME",
      new Integer(50),
      null);

    The results are sorted by name. The query returns an array containing the first 50 sorted originating templates.

  2. Create an input message of the appropriate type.
    TaskTemplate template = taskTemplates[0];
    
    // create a message for the selected task
    ClientObjectWrapper input = task.createInputMessage( template.getID());                       
    DataObject myMessage = null ;
    if ( input.getObject()!= null && input.getObject() instanceof DataObject )
    {
      myMessage = (DataObject)input.getObject();
      //set the parts in the message, for example, a customer name
      myMessage.setString("CustomerName", "Smith");
    }
  3. Create the task and run the task synchronously.

    For a task to run synchronously, it must be a two-way operation. The example uses the createAndCallTask method to create and run the task.

    ClientObjectWrapper output = task.createAndCallTask( template.getName(), 
                                                         template.getNamespace(),
                                                         input);
  4. Analyze the result of the task.
    DataObject myOutput = null;
    if ( output.getObject() != null && output.getObject() instanceof DataObject )
    {
      myOutput  = (DataObject)output.getObject();
      int order = myOutput.getInt("OrderNo");
    }
Related concepts
Queries on business-process and task-related objects

Terms of use | | Broken links

Last updated: Tue Feb 21 17:21:51 2006

(c) Copyright IBM Corporation 2005.
This information center is powered by Eclipse technology (http://www.eclipse.org)