Running a microflow that contains a non-unique starting service

A microflow can be started by a receive activity or a pick activity. The starting service is not unique if the microflow starts with a pick activity that has multiple onMessage definitions.

Why and when to perform this task

If the microflow implements a request-response operation, that is, the process contains a reply, you can use the call method to run the process passing the ID of the starting service in the call.

If the microflow is a one-way operation, use the sendMessage method to run the process. This method is not covered in this example.

Steps for this task

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

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

    ProcessTemplateData[] processTemplates = process.queryProcessTemplates
    ("PROCESS_TEMPLATE.EXECUTION_MODE.EXCECUTION_MODE_MICROFLOW",
     "PROCESS_TEMPLATE.NAME",
      new Integer(50),
      null);

    The results are sorted by name. The query returns an array containing the first 50 sorted templates that can be started as long-running processes.

  2. Determine the starting service to be called.

    This example uses the first template that is found.

    ProcessTemplateData template = processTemplates[0];
    ActivityServiceTemplateData[] startActivities = 
            process.getStartActivities(template.getID());
  3. Start the process with an input message of the appropriate type.

    When you create the message, you must specify its message type name so that the message definition is contained.

    ActivityServiceTemplateData activity = startActivities[0];
    //create a message for the service to be called
    ClientObjectWrapper input = 
          process.createMessage(activity.getServiceTemplateID(),
                                activity.getActivityTemplateID(),
                                activity.getInputMessageTypeName());
    DataObject myMessage = null;
    if ( input.getObject()!= null && input.getObject() instanceof DataObject )
    {
      myMessage = (DataObject)input.getObject();
      //set the strings in the message, for example, a customer name
      myMessage.setString("CustomerName", "Smith");
    }
    //run the process
    ClientObjectWrapper output = process.call(activity.getServiceTemplateID(),
                                              activity.getActivityTemplateID(),
                                              input); 
    //check the output of the process, for example, an order number 
    DataObject myOutput = null;
    if ( output.getObject() != null && output.getObject() instanceof DataObject )
    {
      myOutput  = (DataObject)output.getObject();
      int order = myOutput.getInt("OrderNo");
    }

    This action creates an instance of the process template, CustomerTemplate, and passes some customer data. The operation returns only when the process is complete. The result of the process, OrderNo, is returned to the caller.

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)