/wsdl-first-quarkiverse-cxf-aws-lambda-sample

Sample project for a WSDL/ Contract First service using Quarkus, CXF and AWS Lambda

Primary LanguageJavaApache License 2.0Apache-2.0

Modernize APIs to run serverless using Apache CXF

This example combines the WSDL-first CustomerService sample from Apache CXF with Quarkus to deploy it in a serverless fashion using AWS Lambda.

Prerequisites

Please follow the prerequisites in the Quarkus Guide.

Java runtime

Build

mvn clean package

Deploy

sam deploy -t target/sam.jvm.yaml -g --stack-name cxf-wsdl-first-sample-app

Confirm (with y) that it's ok do not have authorization for testing.

Test

  1. Copy the URL (similar to http://XXXXX.execute-api.REGION.amazonaws.com/) from the Outputs and append services/customerService.

  2. Run

    curl -X POST -d '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cus="http://customerservice.example.com/"><soapenv:Body><cus:getCustomersByName><name>My test customername</name></cus:getCustomersByName></soapenv:Body></soapenv:Envelope>' http://XXXXX.execute-api.REGION.amazonaws.com/services/customerService | xmllint --format -
    

Logs

Check the logs for Init Duration:

sam logs --stack-name cxf-wsdl-first-sample-app --start-time '1min ago' 

Likely it is a high value (>5000ms).

Activate AWS Lambda SnapStart

AWS Lambda SnapStart helps optimizing the coldstart time. Add the following to the Properties section of target/sam.jvm.yaml:

SnapStart:
  ApplyOn: PublishedVersions
AutoPublishAlias: SnapStart

Redeploy and test as above.

Custom runtime (GraalVM)

Build

mvn clean package -Dnative

Check the Quarkus guide for more detailed instructions (e.g. how to build on Windows).

Deploy

sam deploy -t target/sam.native.yaml -g --stack-name cxf-wsdl-first-sample-native-app

Add ARM64 architecture depending where you are building

Architectures:
  - arm64

Confirm (with y) that it's ok do not have authorization for testing.

Test

See above (but make sure to use the different URL).

Logs

sam logs --stack-name cxf-wsdl-first-sample-native-app --start-time '1min ago' 

The duration compared to the Java runtime above is much lower.