Using an Asynchronous Event Handler to Implement a Simple Mortgage Workflow

Mortgage application consumer and provider processes interact with each other through the message correlation mechanism. The event handler invocation allows for asynchronous event processing and executes the logic parallel to the main business logic of the process.

Procedure

  1. In the samples directory, select core > event > AsyncEventHandler and double-click tibco.bw.sample.core.event.AsyncEventHandler. For more information, see Accessing Samples.
  2. In Project Explorer, expand the tibco.bw.sample.core.event.AsyncEventHandler project.
  3. Set the default ApplicationProfile to match the OS you are running on. For more information, see Setting the Default Application Profile.
  4. Fully expand the Processes directory and double-click the MortgageAppConsumer.bwp and the MortgageAppProvider.bwp processes.
  5. Click Run > Debug Configurations.
  6. At the left hand tree of Debug Configuration wizard, expand BusinessWorks Application and select BWApplication.
  7. Click the Applications tab and then click the Deselect All button if you have multiple applications. Select the check box next to tibco.bw.sample.core.event.AsyncEventHandler.application.
  8. Click Debug.
    This runs the sample in Debug mode.
  9. Click the Terminate icon to stop the process.

Result

On the console, the log messages are displayed similar to the following:

12:19:45.639 [bwThread:In-Memory STWorkProcessor-2] INFO c.t.b.p.g.L.t.b.s.c.e.A.LogSubmitMortgage - ### Received SubmitMortgageApp()

12:19:45.670 [bwThread:In-Memory STWorkProcessor-4] INFO c.t.b.p.g.L.t.b.s.c.e.A.Log - Cancel Application F54734546

12:19:45.685 [bwThread:In-Memory STWorkProcessor-4] INFO c.t.b.p.g.L.t.b.s.c.e.A.Log - Cancel Application F54734546

12:19:45.685 [bwThread:In-Memory STWorkProcessor-4] INFO c.t.b.p.g.L.t.b.s.c.e.A.Log - Cancel Application F54734546

12:19:45.701 [bwThread:In-Memory STWorkProcessor-8] INFO c.t.b.p.g.L.t.b.s.c.e.A.Log - ### Done, get Mortgage Rate: 9.1

Understanding the Configuration

There are two processes in the supplied project:
  • MortgageAppProvider: This is a Mortgage service with three operations, the SubmitMortgageApp, SubmitFinDoc and the CancelMortgageApp operations defined in the event handler container. Both the CancelMortgageApp and SubmitFinDoc operations have a correlation key obtained from the response to the operation SubmitMortgageApp.
  • MortgageAppConsumer: The consumer invokes the CancelMortgageApp operation before the operation SubmitFinDoc: This way, the service calls CancelMortgageApp after receiving the correlation message key, mortgageAppID: The CancelMortgageApp activity has the input properties configured as shown in the following image: