Before 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?
- Access to an instance of Oracle Application Container Cloud Service
- Downloaded invoke-worker-web-app.zip
Configure the Worker Application for Cloud Deployment
- Extract the contents of the
invoke-worker-web-app.zip
file. - In the
rest-api-worker-app
directory, create themanifest.json
file with the following content:{ "runtime":{ "majorVersion":"8" }, "command": "node server.js", "release": {}, "notes": "", "type":"worker", "isClustered": true }
- Create a zip file named
worker-app
with the contents of therest-api-worker-app
directory.
Deploy the Worker Application to Oracle Application Container Cloud Service
- Open the Oracle Application Container Cloud Service console.
- In the Applications list view, click Create Application and select Node.
- In the Application section, enter
EmployeeAPI
for the name of your application and click Browse. - In the File Upload dialog box, select
the
worker-app.zip
file and click Open. - Keep the default values in the Instances and Memory fields. Click Create.
Configure the Web Application to Invoke the Worker Application
- In the
client-web-app
directory, create themanifest.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" }
- In the text editor, open the
app.py
file and update theurl
variable with the name of your worker application.url = 'http://EmployeeAPI:8080/employees';
- Create a zip file named
web-app
with the contents of theclient-web-app
directory.
Deploy the Web Application to Oracle Application Container Cloud Service
- Open the Oracle Application Container Cloud Service console.
- In the Applications list view, click Create Application and select Python.
- In the Application section, enter
EmployeesClient
for the name of your application and click Browse. - In the File Upload dialog box, select the
web-app.zip
file and click Open. - Keep the default values in the Instances and Memory fields. Click Create.
Test the Worker Application from the Web Application
- In the Applications list view, click the URL of the web application.
The list of employees is loaded from the worker application.
Description of the illustration web-application.png - Test the Add New, Delete, Update, and Search options.