Use case for Bridge: Connect with remote databases using Bridge

Use case for Bridge: Connect with remote databases using Bridge

Most organizations secure their remote databases using firewalls. If you are looking for a way to navigate these firewalls to access remote databases, Bridge can be of help.

Let us try to solve a real-time business case where Bridge is used to access a MySQL database inside a private network.

 

Business Scenario   

Swerio Corp maintains all their data in a MySQL database inside their secure private network. They use Qntrl for automating different workflows. In one such workflow—Leave Approval, they are looking to retrieve the employees' remaining leave balance for the current year and display it in Qntrl. If the leave balance is sufficient, the card will be sent to the employee’s manager for approval. Else, if the leave balance is nil or less than the requested number of leaves, the card must be automatically rejected.

 

Also, once the leave is approved in Qntrl, the remaining leave balance must be updated in the client’s MySql database as well, thus maintaining uniform data throughout.

 

Solution   

To address this business case effectively, you can create a Board with required fields for the leave request form and utilize a combination of Bridge and Custom Function functionalities.

Implementation 

Follow the steps below to implement the solution:

Step 1: Configure Bridge   

Bridge is an installable Java application that runs on the customer’s local network to facilitate communication between a Qntrl instance and the client’s application inside the firewall.

Create a bridge and configure the Bridge’s agent from your Windows or Linux machine. Get to know the step-by-step process to run a bridge from our help documentation.


Step 2: Create Messages in Bridge   

Create two messages in bridge to hold basic details like module used, database query, bridge values, etc. We will later use these messages to communicate with the database. Click here to learn about the execution of messages in bridge.

 

Message 1: Retrieve Employee Details



Message 2: Update Remaining Leaves


Step 3: Create a Connection

Create a Connection. While creating a connection, use the following scopes:

  1. Orchestly.job.ALL

  1. Orchestly.message.CREATE

  1. Orchestly.message.UPDATE


Step 4: Create Custom Functions

The Function has to be executed 'on-create' stage of a card by configuring in Business RuleCode custom functions to

Retrieve data from the MySql server.



Update data inside MySql server



Here’s the code to retrieve employee details from the SQL database:
//Fetching selected employee details from local database
params = Map();
data = '{"task_name": "db_task","credential": {"name": "mysql"},"task_details": {"database": "DEMO","db_query": "SELECT * FROM Employees where EMP_ID =' + "'" + emp_id + "'" + '","port": 3306,"query_timeout": 10000,"host": "localhost","sql_type": 1,"connection_timeout": 10000,"allow_multiple_columns": true}}';
params.put("data",data);
resp = invokeurl
[
      url :"https://core.qntrl.in/blueprint/api/manikin001/message/6124000000050437"
      type :POST
      parameters:params
      connection:"<CONNECTION NAME>"
];
info resp;
response = resp.get("response_to").getJSON("results");
//Updating employee details in the current job
if(response != null)
{
  d = response.get(0);
  job_params = Map();
 name = d.get(1);
 job_params.put("customfield_shorttext1",name);
 email = d.get(2);
 job_params.put("customfield_shorttext2",email);
  remaining_leaves = toNumber(d.get(3));
  job_params.put("customfield_integer1",remaining_leaves);
 r = invokeurl
 [
  url :" https://core.qntrl.in/blueprint/api/manikin001/job/" + job_id
  type :POST
  parameters:job_params
  connection:"<CONNECTION NAME>"
  ];
}

Here’s the code to update employee details to the SQL database:
remaining_days = remaining_leaves.toLong();
params = Map();
data = '{"task_name": "db_dml_task","credential": {"name": "mysql"},"task_details": {"database": "DEMO","db_query": {"update":["UPDATE Employees set REMAINING_LEAVES = ' + "'" + remaining_days + "'" + ' where EMP_ID =' + "'" + emp_id + "'" + '"]},"port": 3306,"query_timeout": 10000,"host": "localhost","sql_type": 1,"connection_timeout": 10000}}';
params.put("data",data);
resp = invokeurl
[
      url :"https://core.qntrl.in/blueprint/api/manikin001/message/6124000000050557"
      type :POST
      parameters:params
      connection:"<CONNECTION NAME>"
];
info resp;


Step 5: Create a Card in the Leave Request Board

Initiate leave requests by creating a new card within the board. Refer to the resources for guidance on creating new cards within the board interface. Here is the sample card template to get the employee inputs for leave request devised by Swerio.



The leave Request card comprises fields such as 'Employee ID', 'Date from', 'Date to', and 'Reason for leave'. Upon completion of the Employee ID field, other pertinent employee details are automatically retrieved from the database.

Upon entry of the 'Date from' and 'Date to' fields, the system calculates the difference between them and validates it against the 'Remaining Leaves' field. If the disparity is equal to or less than the remaining leaves, the card is forwarded to the manager for approval. Conversely, if the difference exceeds the remaining leaves, the card is automatically declined.



Upon the manager's approval of the card, the 'Remaining Leaves' field is updated. Additionally, a second custom function is activated to synchronize this updated value with the client's database.





    • Related Articles

    • Install Bridge

      Follow the below step-by-step procedures to configure and use Bridge in Qntrl. Step 1: Download the Bridge agent Only one Bridge agent can be installed per machine. To download a bridge agent in Qntrl: Navigate to (settings), under Advanced click ...
    • Overview of Bridge

      What is a Bridge? Bridge is an installable, lightweight independent agent that can be deployed on the customer’s local network. It is compatible both on Windows and Linux machines with 32 and 64-bit OS. Its role is to facilitate communication between ...
    • Bridge agent settings

      Once the Bridge agent is set up, you can log in to the bridge agent to view and modify the allowed configuration as needed. To do this: In Qntrl, navigate to (settings) >> Advanced >> Bridge, then select your bridge. Hover your cursor over the bridge ...
    • Other actions in Bridge

      View / Edit Bridge properties Follow the given steps to view or edit the properties of a bridge: Click the settings gear icon located in the left pane. Navigate to Advanced >> Bridge >> choose Bridge. In the Bridge list page, choose the specific ...
    • Sample Use Case - Configuring Input and Output Processing in Circuit console

      Let's explore Input/Output Processing further by building a Circuit using the example of an Employee Onboarding Process. We initiate the process with the following state Input which contains information about the employee details for employee ...

    You are currently viewing the help articles of Qntrl 3.0. If you are still using our older version and require guidance with it, Click here.