22. The Credit Card Raise Approval Project
In this use case we would like to handle the automation of a credit limit increase approval process. Most card issuers allow customers to request an increased credit limit through various entry points such as: websites, their mobile applications or over the phone with customer service. Let’s consider we need to deliver this automation for a bank that wants to achieve a similar use case within an event-driven architecture.
The existing process is started via REST. It has a step for automatic request validation using DMN, and if the request not approved, it goes to a manual review queue. If approved, the service responsible for updating the cc limit is invoked via REST (the diagram only represents this REST call with a script task since this is not relevant for this lab's scenario). Finally, the process ends either with an approved or denied request.
Now, with the architecture shift, the service responsible for increasing the credit card limit should not be invoked via REST anymore. The external service now listens to the topic “request-approved” in order to track when to execute the limit raise. The business process should get started based on events, and whenever the process finishes, it should post a message to a specific topic depending on whether the request was approved or not.
Process v2. Whenever a new event happens in a topic, a new instance will be triggered. Depending on how this process ends, an event is published in a different topic, therefore, different services can react based on the approval status.
In this strategy we have a resilient way of communication between services where the broker is responsible for storing and providing the events. Adding to that, the tech team can evolve the solutions by using the features available in Kafka itself, like the possibility to replay all the events that happened in a specific time, in chronological order.
22.1 Importing the project
Let's import the existing project so we can start implementing the eventing capabilities.
Access Business Central, and import the following project: https://github.com/kmacedovarela/cc-limit-approval-app-step1
Let's check the existing project. Open the
cc-limit-raise-approvalprocess. Notice that currently it is a traditional process, with a standard start and stop node. Processes like this can be started either via REST or JMS.
22.2 Reacting to events
The first task we'll do, is to enable the existing process to react to events that are published in a specific topic. Whenever a new event is published, a new process instance should be created.
To allow this process definition to be started with events, the first step is to change the start event to a Start Message Event by clicking the node in the editor and selecting the envelope icon to "Convert into Start Message":
Whenever a customer make a new request (independently of the channel used) an event should be published on the
topic. This way as new channels are ready to be added, they just need to point to this request instead of modifying for the process end point. With that, a new process instance should be started whenever a new event is published in this topic. Let's configure the Start Message Event with the
🚧 WARN: we need to receive the data that is the event data. The KIE Server provides automatic marshalling to help us mapping the input directly to a Data Object (a POJO). This project has an object named
LimitRaiseRequest.javawhich we will use to receive the incoming data and feed it in the process.
On the properties panel of the Start Message Event, configure the input data:
- Name: request
- Data Type:
- Target: request
Save the process. Your process should now look like this:
22.3 Deploying the project
Now, let's deploy and test the project.
On the breadcrumb, click on "cc-limit-approval-app-step1" to go back to the Project Explorer view.
Click on the "Deploy" button.
22.4 Testing the project
Let's publish a new event in the
incoming-requests topic using the Kafka producer CLI tool.
Open a new tab in your terminal and access the
Next, use the Kafka producer to publish new messages on the topic
You can send the following data, and press enter:
Back to the browser, open Business Central. On the top menu, go to Menu -> Manage -> Process Instances.
On the left column, filter by "Completed" State. You should see as many instances as the number of events you published on Kafka:
Select a process instance, and next, select the tab
Diagram. You should see something like: