Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Stardust/Knowledge Base/API/ExamplesofAPIUsage/StartProcess

Start a Process

Purpose

Creating and starting a process instance is quite easy via the API. Each process instance will process its activity instances until it has to wait on an external event like a JMS response, a mail or a user interaction.

Requirements

You need an Initialized workflow service and the id of the process definition you want to start. Reference Model.

Stardust Embedded API Start Process

Implementation

Exception handling

To keep the example code clear the exception handling is very simple. If you use this code productive, please add appropriate exception handling!

Missing parts

The missing code fragments ([...]) can be found here.

package com.sungard.wiki;
 
import ag.carnot.workflow.runtime.ProcessInstance;
import [...];
 
public class WikiProgram {
	[...]
	public static void main(String[] unused) {
		try {
    		    init();
		    ProcessInstance lProcessInstance = startProcess();
			// Do stuff with the process instance here
		} finally {
			uninit();
		}
	}
 
	static ProcessInstance startProcess() {
		ProcessInstance lProcessInstance = workflowService.startProcess("DoWhileLoop", Collections.EMPTY_MAP, true);
		return lProcessInstance;
	}
	static void init() {[...]}
	static void uninit() {[...]}
}

As you can see, the API call to start the process is quite simple

  • Just provide the ID of the process definition.
  • As long as you don't need any in data you can provide an empty map. Otherwise you can inject your data via this collection.
  • The started process instance will proceed until it reaches an interactive activity (or until it has to wait for an external event).



Copyright © Eclipse Foundation, Inc. All Rights Reserved.