Invoking asynchronous service using message events

Your BPM process can invoke other processes and services in many ways. It could be messages, send or receive tasks, signals, calls, service tasks, and so on. Generally, it's the operations used to communicate with other process or service. It could be synchronous or asynchronous.

You have the SaveQuote service, which you have used up until this point, to save quote information to a file location. It's an asynchronous service that you have created. You will learn to use the message throw event to invoke this service and a message catch event to receive a call-back of the asynchronous service.

How to do it...

In this section, you will learn to invoke an asynchronous service using message events:

  1. Navigate to JDeveloper | SalesToContractDemo and click on the SalesToContract process.
  2. You will locate the point where you need to perform an asynchronous service invocation and call-back. In the contracts swimlane, just after the Contract Finalize service task, you will use the indicated first point for service invocation and second point for service call-back:
    How to do it...
  3. Go to Component Palette | BPM | Events and click on Throw Message Event.
  4. Drag-and-drop it to point 1 between the Contract Finalize and Save Quote tasks. This will open the Properties dialog.
  5. Enter the name of the message event as Invoke_SaveQuote, in the Basic tab.
  6. In the Implementation tab, let the Implementation Type be Message and select Initiates for Conversation
  7. In the Properties dialog, select Service Call.
  8. Click on the "browse" button next to Name, to browse for an asynchronous service.
  9. From the Type dialog, select the SaveQuote asynchronous service and click on OK.
    How to do it...
  10. Select the operation to invoke from the service.
  11. Click on Data Association and assign quote object as input argument to the service.
  12. Click on OK.
  13. When you have finished this, click on Save.
  14. Go to Component Palette | BPM | Events and click on Catch Message Event.
  15. Drag-and-drop it to point 2, between Invoke_SaveQuote Event and End Activity. This will open the Properties dialog.
  16. Enter Callback_SaveQuote as the name, in the Basic tab.
  17. In the Implementation tab, let the Implementation Type be Message and select Continues for Conversation.
  18. You will find that Initiator Node appears.
  19. You have to select an activity that invokes the asynchronous service. You can select Invoke_SaveQuote.
  20. You will find that the Name field and Operations will auto-populate.
    How to do it...
  21. When you have finished this, click on Save.
  22. You can find a slightly renovated process design, as follows:
    How to do it...

How it works...

Invocation is carried out by the throw message event, which is configured to initiate a conversation. The BPMN service engine performs the invocation and callback.

  • The BPMN service engine will do the following:
    • First, run the throw event
    • Create an XML message based on the asynchronous operation that it's invoking
    • Send this XML message to the invoked service
    • Send a token to catch the message event
  • An asynchronous service will do the following:
    • Receive the message
    • Run the operation
    • When finished, send a message with response to the service that invoked it
    • Catch the message event
    • Wait for a response from the call-back operation
    • This message catch event continues the conversation and uses the message throw event that invoked the operation as the initiator event.

    Note

    If the service is still running when BPMN Service Engine runs the message catch event, then the engine waits for the service operation to complete before passing the token to the next flow object in the process. Oracle BPM Suite supports automatic correlation through WS-Addressing headers. If you need a message-based correlation, the approach is to delegate the correlation tasks to a BPEL process. However, with Oracle BPM Suite 11g FP, out of the box support for message-based correlation is provided in addition to automatic correlation. Correlation keys can be based on one or more correlation properties to form a unique key to locate the process instance. Just as you set data association, you can use the wizard to define correlation keys.

There's more...

Here you will learn to invoke an asynchronous BPMN process:

Invoking an asynchronous BPMN Process

An asynchronous BPM process can be invoked using the message throw event. The invoked BPM process response can be obtained by invoking the service call-back operation using a message catch event:

  1. Find a point in the BPM process where you need to invoke another BPM process.
  2. Drag-and-drop message throw event from the Component Palette to that point.
  3. In the Properties of Throw Message Event, set Conversation to Initiates.
  4. Select Process Call as Implementation.
  5. Click on the "browse" button to browse for the process and select an asynchronous BPM process.
  6. Select the node from the node list.
  7. Use data association to assign parameters to invoke the BPM process.
    Invoking an asynchronous BPMN Process
  8. Drag-and-drop the catch message event to the point where you want to invoke call-back operation of the asynchronous BPM process.
  9. In the Implementation tab of properties of the message catch event, select Continues as the Conversation type.
  10. 10 .In the Initiator Node, select the activity that invoked the asynchronous BPM process.
  11. In the Node list, select Invoke as the callback operation.
  12. When you have finished this, click on Save.

Send and receive task to invoke asynchronous service operations

You can use send and receive tasks too for invoking asynchronous services and BPMN processes.

  1. Select the process on which you want to invoke an asynchronous service operation.
  2. Drag-and-drop a Send task from the component palette.
  3. In the Implementation tab of the properties, set the Conversation type to Initiates.
  4. Browse for the asynchronous service and select the server from the list.
  5. Select the asynchronous service operation.
  6. Perform data association if asynchronous service requires input arguments.
  7. When you have finished this, click on Save.
  8. Drag-and-drop a Receive task from Component Palette to the point where you want to invoke the call-back operation of the asynchronous service.
  9. In the Implementation tab of the Properties, set Conversation type to Continuous.
  10. From the Initiator Node list, select the activity in your process that invokes the asynchronous service.
  11. Browse for the asynchronous service whose call-back you want to invoke.
  12. Select the call-back operation from the operations list.
  13. When you have finished this, click on Save.

Deploying and testing

Deploy the process, as shown in the following steps, in Chapter 3, Deploying the BPM project. You can test the process up to this stage:

  • Log in to BPM workspace as sales representative user.
  • Enter Quote details.
  • Advance the process till Contract Finalize.
  • Finalize the contract.
  • Log in to Oracle EM Console.
  • You can find a completed instance created for the SalesToContract process.
  • Click on the instance and go to trace.
  • Click on the name of the process SalesToContract.
  • Click on the Flow tab.
  • You will find that the process token followed the desired path of Throw and Catch Message Events. You can find a quote.xml file created at the specified location, too:
    Deploying and testing
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.43.36