+

Search Tips   |   Advanced Search


Initiating a process instance

Develop the code within the portlet that will start an instance of a process in a business process application. Refer to the code samples provided. You should be familiar with WebSphere Process Server Business Flow Manager API documentation.

To initiate a process instance from within a portlet...

  1. 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;
    
    

  2. After you deploy the process, use the Administrative Console of the appserver to map the reference to the BusinessProcess session bean. The default JNDI name is cell/persistent/pi/BFMHome..

  3. 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 custom user interfaces for process integration


Previous topic:

Creating Task Processing portlets


Related information


WebSphere Process Server library