Injecting a Pageflow Event

You can inject data into a pageflow process multiple times while it is in progress, regardless of whether the flow from any previous occurrence is still in progress.

You can use an event handler to do so. An event handler is a catch intermediate event with no specific trigger and incoming flow that can be triggered by an external client application using the BPM API. Note that the event handler does not have to happen for the pageflow process to complete.

You can update a pageflow local data cache using an event handler. For example, an event handler updates the exchange rate information regularly. A pageflow process used to manage an order request can use the updated exchange rate information when issuing an invoice.

The example here illustrates injecting a pageflow event. It involves listing all the deployed pageflows, starting a pageflow, and while it is running, injecting a pageflow event.

Injecting a Pageflow Event

The following step-by-step descriptions correspond to the numbered steps in the illustration above. Note that the descriptions are from a web service operation point of view, and provide an example of performing the operations using the web service API (SOAP).

Procedure

  1. Find out the list of deployed pageflows by calling the listPageFlows operation. This operation returns the module version number, which is required as an input when calling the startPageFlow operation.
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pag="http://pageflow.api.pfe.n2.tibco.com">
       <soapenv:Header/>
    <soapenv:Body>
          <pag:listPageFlows startPosition="0" numberOfItems="10" getTotalCount="true">
             <includeFormalParameters>true</includeFormalParameters>
          </pag:listPageFlows>
       </soapenv:Body>
    </soapenv:Envelope>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
       <SOAP-ENV:Header/>
    <SOAP-ENV:Body>
          <listPageFlowsResponse xmlns="http://pageflow.api.pfe.n2.tibco.com">
             <startPosition xmlns="">0</startPosition>
             <totalItems xmlns="">3</totalItems>
             <pageFlowTemplate hasFormalParameters="true" moduleName="/PageflowSolution/Process Packages/ProcessPackage.xpdl" processName="RequestAdditionalDataPageflow" version="1.0.0.201108111516" xmlns=""/>
             <pageFlowTemplate hasFormalParameters="false" moduleName="/APH_WelcomeUsersImplementSolution/Process Packages/aph_test.xpdl" processName="GetName" version="1.0.0.201108111305" xmlns=""/>
             <pageFlowTemplate hasFormalParameters="true" moduleName="/Inject/Process Packages_Inject/ProcessPackage.xpdl" processName="ProcessPackageProcess" version="1.0.0.201108161050" xmlns=""/>
          </listPageFlowsResponse>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
  2. You can choose to start one of the pageflows returned in Step 1. Call the startPageFlow operation and specify the parameters module name and process name to start the selected pageflow. This operation returns the instance ID, which is required for the next step, injecting a pageflow event.
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pag="http://pageflow.api.pfe.n2.tibco.com">
       <soapenv:Header/>
    <soapenv:Body>
          <pag:startPageFlow>
             <pageFlowDefinition moduleName="/Inject/Process Packages_Inject/ProcessPackage.xpdl" processName="ProcessPackageProcess" version="1.0.0.201108161050"/>
             <formalParams payloadMode="XML">
                 <XmlPayload>
                      <inputs name="Names" type="Text" optional="true" array="false">
                      <simpleSpec length="50">
                         <value>TIBCO</value>
                      </simpleSpec>
    </inputs>
                </XmlPayload>
             </formalParams>
             <responsePayloadMode>XML</responsePayloadMode>
          </pag:startPageFlow>
       </soapenv:Body>
    </soapenv:Envelope>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
       <SOAP-ENV:Header/>
    <SOAP-ENV:Body>
          <startPageFlowResponse xmlns="http://pageflow.api.pfe.n2.tibco.com">
             <pageResponse executionState="IN_PROGRESS" xmlns="">
                <context>
                   <pageFlowTemplate hasFormalParameters="false" moduleName="/Inject/Process Packages_Inject/ProcessPackage.xpdl" processName="ProcessPackageProcess" version="1.0.0.201108161050"/>
                   <processReference>
                      <id>pvm:0a101f</id>
                      <name>ProcessPackageProcess</name>
                   </processReference>
                </context>
                <pageData>
                   <pageReference activityId="pvm:001g1f.5" activityModelId="_VK4SIKh8EeCt2PSB39ZXYA" activityName="UserTasks" moduleName="/Inject/Process Packages_Inject/ProcessPackage.xpdl" moduleVersion="1.0.0.201108161050" processName="ProcessPackageProcess"/>
                   <payload payloadMode="XML">
                      <XmlPayload/>
                   </payload>
                </pageData>
             </pageResponse>
          </startPageFlowResponse>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
  3. While the pageflow is running, you can inject a pageflow event using the injectPageFlowEvent operation. The request message requires you to provide the following parameters: moduleName, processName, eventName, processInstanceId (optional), formal parameters, payload, and optionally, the responsePayloadMode. This operation updates the value of the specified parameter(s) with the value(s) injected by the intermediate event.
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pag="http://pageflow.api.pfe.n2.tibco.com">
       <soapenv:Header/>
    <soapenv:Body>
          <pag:injectPageFlowEvent>
             <eventDefinition moduleName="/EventHandler/Process Packages/EventHandler.xpdl" processName="EventHandlerProcess2" eventName="IntermediateEvent" processInstanceId="pvm:0a101u"/>
             <formalParams payloadMode="XML">
                <XmlPayload>
    <inputs array="false" name="Parameter" optional="false" type="String">
    <simpleSpec length="50">
                         <!--Zero or more repetitions:-->
                         <value>TIBX</value>
                      </simpleSpec>
                   </inputs>
    <inputs array="false" name="Parameter2" optional="false" type="Integer Number">
    <simpleSpec length="9">
                         <!--Zero or more repetitions:-->
                         <value>147</value>
                      </simpleSpec>
                   </inputs>
    </XmlPayload>
          </formalParams>
        </pag:injectPageFlowEvent>
       </soapenv:Body>
    </soapenv:Envelope>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
       <SOAP-ENV:Header/>
    <SOAP-ENV:Body>
          <injectPageFlowEventResponse xmlns="http://pageflow.api.pfe.n2.tibco.com">
             <pageResponse executionState="IN_PROGRESS" xmlns="">
                <context>
                   <pageFlowTemplate hasFormalParameters="false" moduleName="/EventHandler/Process Packages/EventHandler.xpdl" processName="EventHandlerProcess2" version="1.0.0.201108161235"/>
                   <processReference>
                      <id>pvm:0a101u</id>
                      <name>EventHandlerProcess2</name>
                   </processReference>
                </context>
                <pageData>
                   <pageReference activityId="pvm:001g1u.9" activityModelId="_eMANL720EeC61dgFHyHHpQ" activityName="UserTask3" moduleName="/EventHandler/Process Packages/EventHandler.xpdl" moduleVersion="1.0.0.201108161235" processName="EventHandlerProcess2"/>
                   <payload payloadMode="XML">
                      <XmlPayload>
                         <inputs array="false" name="Parameter" optional="true" type="String">
                            <simpleSpec>
                               <value>[Ljava.lang.String;@2818fe57</value>
                            </simpleSpec>
                         </inputs>
                         <inputs array="false" name="Parameter2" optional="true" type="Integer Number">
                            <simpleSpec>
                               <value>[Ljava.lang.String;@e21652</value>
                            </simpleSpec>
                         </inputs>
                         <inouts array="false" name="Field" optional="true" type="String">
                            <simpleSpec/>
                         </inouts>
                      </XmlPayload>
                   </payload>
                </pageData>
             </pageResponse>
          </injectPageFlowEventResponse>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>