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.zipfile. - In the
rest-api-worker-appdirectory, create themanifest.jsonfile with the following content:{ "runtime":{ "majorVersion":"8" }, "command": "node server.js", "release": {}, "notes": "", "type":"worker", "isClustered": true } - Create a zip file named
worker-appwith the contents of therest-api-worker-appdirectory.
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
EmployeeAPIfor the name of your application and click Browse. - In the File Upload dialog box, select
the
worker-app.zipfile 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-appdirectory, create themanifest.jsonfile 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.pyfile and update theurlvariable with the name of your worker application.url = 'http://EmployeeAPI:8080/employees'; - Create a zip file named
web-appwith the contents of theclient-web-appdirectory.
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
EmployeesClientfor the name of your application and click Browse. - In the File Upload dialog box, select the
web-app.zipfile 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.
Invoke a Worker Application from a Web Application