Initiating a process instance
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. For further information see the Information Center for WebSphere Business Integration Server Foundation and the Process Choreographer API documentation.
First, the portlet needs to use a JNDI lookup to obtain a reference to the process choreographer remote EJB interface.
// Obtain the default initial JNDI context Context initialContext = new InitialContext(); // Lookup the remote home interface of the BusinessProcess bean Object result = initialContext.lookup("java:comp/env/ejb/BusinessProcessHome"); // Convert the lookup result to the proper type BusinessProcessHome processHome = (BusinessProcessHome)javax.rmi.PortableRemoteObject.narrow (result,BusinessProcessHome.class); // Access the remote interface of the BusinessProcess session bean BusinessProcess process = processHome.create();After deployment, be sure to use the appserver's admin console to map the reference to the BusinessProcess session bean. The default jndi name is com/ibm/bpe/api/BusinessProcessHome.
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 = process.getProcessTemplate(templateName); // Create a message for the single starting receive activity ClientObjectWrapper input = process.createMessage (template.getID(), template.getInputMessageTypeName()); WSIFMessage myMessage = input.getObject(); // Set the message parts, for example, the travel destination ... myMessage.setObjectPart("Destination", "New York"); ... //start the process PIID piid = process.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.
See also
- Business process integration scenario
- Integrating business processes
- WebSphere Business Integration Server Foundation Information Center
Home |
WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.
IBM is a trademark of the IBM Corporation in the United States, other countries, or both.