Initiating a process instance

 

+

Search Tips   |   Advanced Search

 

This section provides an example of how to initiate a process instance.

For example, you could use this kind of code from a portlet that starts an instance of a process. See...

http://www.ibm.com/software/integration/wps/

..for IBM WebSphere Process Server and the Process Choreographer API documentation.

First, the portlet needs to use a JNDI lookup to obtain a reference to the process server remote EJB interface.

// Obtain the default initial JNDI context Context initialContext = new InitialContext();
        
// Lookup the remote home interface of the BusinessFlowManager bean Object result = initialContext.lookup("java:comp/env/ejb/BusinessFlowManagerHome");

// Convert the lookup result to the proper type BusinessFlowManagerHome processHome = (BusinessFlowManagerHome) 
  javax.rmi.PortableRemoteObject.narrow(result, BusinessFlowManagerHome.class);

// Create BusinessFlowManager flowManager = processHome.create();

return flowManager;

After deployment, be sure to use the application server's admin console to map the reference to the BusinessProcess session bean. The default jndi name is...

com/ibm/bpe/api/BusinessFlowManagerHome

Next, the portlet needs to start the process with an input message of the appropriate type.

When you create the message, specify its message type name so that the message definition is contained. If you specify a process-instance name for the process instance to be created, it must not start with an underscore. If a process-instance name is not specified, the process instance ID (PIID) in String format is used as the name.

ProcessTemplateData template =
flowManager.getProcessTemplate(templateName);

// Create a message for the single starting receive activity    ClientObjectWrapper input = flowManager.createMessage                        (template.getID(),
                        template.getInputMessageTypeName());

DataObject myMessage = input.getObject();

// Set the message parts, for example, the travel destination 
...
myMessage.setString("Destination", "New York");
...

//start the process PIID piid = flowManager.initiate(template.getName(), ProcessInstanceName, input);

This action creates an instance with name ProcessInstanceName. When the process starts, the operation returns the object ID of the new process instance to the caller.

 

Parent topic:

Develop business process applications

 

Related concepts

Set up the development environment for process applications

 

Related information

WebSphere Process Server - Library
Enable the business process for portal
Create the task processing portlet
Migrate business process applications