Oracle by Example brandingInvoke a Worker Application from a Web Application

section 0Before You Begin

This 15-minute tutorial shows you how to invoke a worker application from a web application in Oracle Application Container Cloud Service.

Background

Oracle Application Container Cloud Service supports two types of applications:

  • Web: A web application is a public application that you can access by using a public URL. By default, all applications in Oracle Application Container Cloud Service are web applications.
  • Worker: A worker application is a private application. It can be invoked only from another (web or worker) application by using an internal overlay network.

Web and worker applications can talk to each other over a secure internal network if all of them are marked as isClustered.

This tutorial shows you how to invoke a worker application developed in Node.js from another application developed in Python. The Node.js application is a REST API that implements the basic REST methods (GET, POST, DELETE, and PUT), and the Python application is the client that consumes the REST API application.

What Do You Need?


section 1Configure the Worker Application for Cloud Deployment

  1. Extract the contents of the invoke-worker-web-app.zip file.
  2. In the rest-api-worker-app directory, create the manifest.json file with the following content:
    {
      "runtime":{
        "majorVersion":"8"
      },
      "command": "node server.js",
      "release": {},
      "notes": "",
      "type":"worker",
      "isClustered": true
    } 
  3. Create a zip file named worker-app with the contents of the rest-api-worker-app directory.

section 2Deploy the Worker Application to Oracle Application Container Cloud Service

  1. Open the Oracle Application Container Cloud Service console.
  2. In the Applications list view, click Create Application and select Node.
  3. In the Application section, enter EmployeeAPI for the name of your application and click Browse.
  4. In the File Upload dialog box, select the worker-app.zip file and click Open.
  5. Keep the default values in the Instances and Memory fields. Click Create.

section 3Configure the Web Application to Invoke the Worker Application

  1. In the client-web-app directory, create the manifest.json file with the following content:
    {
      "runtime": {
        "majorVersion": "3.6.0"
      },
      "command": "sh ./start.sh",
      "isClustered": true,
      "release": {
        "version": "1.0"
      },
      "notes": "Python client application of Employee REST API"
    } 
    
  2. In the text editor, open the app.py file and update the url variable with the name of your worker application.
    url = 'http://EmployeeAPI:8080/employees';
  3. Create a zip file named web-app with the contents of the client-web-app directory.

section 4Deploy the Web Application to Oracle Application Container Cloud Service

  1. Open the Oracle Application Container Cloud Service console.
  2. In the Applications list view, click Create Application and select Python.
  3. In the Application section, enter EmployeesClient for the name of your application and click Browse.
  4. In the File Upload dialog box, select the web-app.zip file and click Open.
  5. Keep the default values in the Instances and Memory fields. Click Create.

section 5Test the Worker Application from the Web Application

  1. In the Applications list view, click the URL of the web application.

    The list of employees is loaded from the worker application.

    Employee client home page
    Description of the illustration web-application.png
  2. Test the Add New, Delete, Update, and Search options.

more informationWant to Learn More?