Lab 03 - Fuse Online

Return to Workshop

Lab 3

Fuse Online


<img src=”../images/agenda-03.png “Login” width="900” />

Overview

When it comes to quick API development, you need both the integration experts as well as application developers to easily develop and deploy the APIs. Here is how to create a simple API with Fuse Online.

Why Red Hat?

Red Hat Fuse integration solution empowers integration experts, application developers, and business users to engage in enterprise-wide collaboration and high-productivity self-service.

Lab Instructions

Step 1: Create database connection

  1. Navigate to OpenShift.

  2. Click on your Tools Project.

  3. Click on your Fuse Online Route and Log In.

  4. The first time that you hit the Fuse Online URL, you will be presented with an Authorize Access page. Click the Allow selected permissions button to accept the defaults.


    <img src=”../images/design-54.png “Accept permissions” width="900” />

  5. Click on Connections > Create Connection


    <img src=”../images/00-create-connection.png “Create Connection” width="900” />

  6. Select Database


    <img src=”../images/01-select-database.png “Select Database” width="900” />

  7. Enter below values for Database Configuration

    Connection URL: jdbc:postgresql://postgresql.international.svc:5432/sampledb
    Username      : dbuser
    Password      : password
    Schema        : <blank>
    

Remember to replace the OCPPROJECT with the OpenShift project(NameSpace) you used in last lab. It should be your username

  1. Click Validate and verify if the connection is successful. Click Next to proceed.


    <img src=”../images/02-click-validate.png “Validate” width="900” />

  2. Add Connection details:

  1. Verify that the Location Database is successfully created.

Step 2: Create webhook integration

Description goes here

  1. Click on Integrations > Create Integration


    <img src=”../images/04-create-integration.png “Create Integration” width="900” />

  2. Choose Webhook


    <img src=”../images/05-choose-weebhook.png “Choose webhook"Integration” width="900” />

  3. Click on Incoming webhook


    <img src=”../images/06-incoming-webhook.png “Add incoming webhook” width="900” />

  4. It navigates to the Webhook Token screen. Click Next


    <img src=”../images/07-webhook-configuration.png “Webhook Configuration” width="900” />

  5. Define the Output Data Type.

  1. Click on LocationDB from the catalog and then select Invoke SQL


    <img src=”../images/09-invoke-sql.png “Invoke SQL” width="900” />

  2. Enter the SQL statement and click Done.

INSERT INTO locations (id,name,lat,lng,location_type,status) VALUES (:#id,:#name,:#lat,:#lng,:#location_type,:#status ) ```

<br><img src="../images/10-invoke-sql-2.png "Invoke SQL 2" width="900" /><br><br>
  1. Click on Add step and select Data mapper


    <img src=”../images/11-data-mapper.png “Data Mapper” width="900” />

  2. Drag and drop the matching Source Data types to all their corresponding Targets as per the following screenshot. When finished, click Done.


    <img src=”../images/12-configure-mapper.png “Configure Mapper” width="900” />

  3. Click Publish on the next screen

  4. Add Integration Name: addLocation.

  5. Again Click Publish.


    <img src=”../images/13-publish-integration.png “Publish Integration” width="900” />

Congratulations. You successfully published the integration. (Wait for few minutes to for the integration to be built and published)

Step 3: Create a POST request

We will use an online cURL tool to create the 101st record field in database. If you’d prefer to use the Terminal in your Che instance, go ahead and skip the online cURL instructions and just use the cURL command in your Che Terminal.

  1. Copy the External URL per the below screenshot


    <img src=”../images/14-copy-URL.png “Copy URL” width="900” />

  2. Open a browser window and navigate to: https://onlinecurl.com/

  3. Below are the values for the request.

  1. The page will load the 204 response information from the service which means the request was successfully fulfilled.
  1. If you are using an Environment with self signed certificates and get an SSL error, you can also use the curl utility in the terminal of your Eclipse Che environment instead of online curl.
  1. Click on Activity > Refresh and verify if the newly record is created.


    <img src=”../images/17-activity-refresh.png “Activity Refresh” width="900” />

  2. (Optional) Visit the application URL in the browser from the Location Service created in the previous lab and verify if the record can be fetched.

RESPONSE

  {
    "id" : 101,
    "name" : "Kamarhati",
    "type" : "Regional Branch",
    "status" : "1",
    "location" : {
      "lat" : "-28.32555",
      "lng" : "-5.91531"
    }
  }

Summary

In this lab you discovered how to create an adhoc API service using Fuse Online.

Notes and Further Reading

Return to Workshop