Skip to content

Latest commit

 

History

History

helidon-quickstart-mp

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Helidon Quickstart MP Example

This example implements a simple Hello World REST service using MicroProfile and shows how to deploy it to Google App Engine.

Build and run

With JDK11

mvn package
java -jar target/helidon-quickstart-mp.jar

Exercise the application

curl -X GET http://localhost:8080/greet
{"message":"Hello World!"}

curl -X GET http://localhost:8080/greet/Joe
{"message":"Hello Joe!"}

curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Hola"}' http://localhost:8080/greet/greeting

curl -X GET http://localhost:8080/greet/Jose
{"message":"Hola Jose!"}

Try health and metrics

curl -s -X GET http://localhost:8080/health
{"outcome":"UP",...
. . .

# Prometheus Format
curl -s -X GET http://localhost:8080/metrics
# TYPE base:gc_g1_young_generation_count gauge
. . .

# JSON Format
curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics
{"base":...
. . .

Running in Google App Engine

Pick a project ID for your project and save it in an environment variable:

export YOUR_PROJECT_ID=[your_project_id]

Replace [your_project_id] with a string of characters that uniquely identifies your project. For example, my-helidon-project-44

Go to the Google App Engine Quickstart for Java 11: and complete the steps under "Before You Begin". Stop when you reach "Download the Hello World app".

Verify your project:

gcloud projects describe $YOUR_PROJECT_ID

If you haven't already done it, build the Helidon example locally:

mvn package

Then deploy it to Google App Engine

gcloud app deploy target/helidon-mp-app.yaml

This will upload files, then deploy the service.

You can view the application in your browser by running:

gcloud app browse

The browser will initially report "No handler found for path: /". That's OK.

You can now exercise the application by modifying the URL to match what was described earlier in this README. For example append `/greet/ to the URL.

Some things to note

  • This example responds to the PORT environment variable as provided by the Google App Engine runtime.
  • By default Helidon packages your application as a "thin" jar file with runtime dependencies external to the jar (in libs). The jar file's META-INF/MANIFEST.MF has Main-Class and Class-Path set appropriately. Google App Engine supports this packaging as long as you use a custom entrypoint as is done in target/helidon-mp-app.yaml.
  • To control what files are uploaded we have src/main/gae/.gcloudignore that gets copied into the target directory. It excludes everything, and then includes only what is needed.

Cleanup!

Make sure to cleanup your application as described in the Google App Engine Quickstart.