Git Product home page Git Product logo

spring-boot-camel-rest-3scale's Introduction

Spring Boot Camel REST 3scale QuickStart

This example demonstrates how to use Camel's REST DSL to expose a RESTful API and expose it to 3scale.

This example relies on the Fabric8 Maven plugin for its build configuration and uses the fabric8 Java base image.

The Fabric8 Maven Plugin discovers service metadata from Camel XML Context's service definition and exposes the following:

Service Label

  • discovery.3scale.net/discoverable: Allows 3scale to select Services that are to be automatically exposed.

Service Annotations

  • discovery.3scale.net/discovery-version: the version of the 3scale discovery process.
  • discovery.3scale.net/scheme: this can be http or https
  • discovery.3scale.net/path: (optional) the contextPath of the service if it's not at the root.
  • discovery.3scale.net/description-path: (optional) the path to the service description document (OpenAPI/Swagger). The path is either relative or an external full URL.

Building

The example can be built with:

$ mvn install

This automatically generates the application resource descriptors and builds the Docker image, so it requires access to a Docker daemon, relying on the DOCKER_HOST environment variable by default.

Running the example locally

The example can be run locally using the following Maven goal:

$ mvn spring-boot:run

Alternatively, you can run the application locally using the executable JAR produced:

$ java -jar -Dspring.profiles.active=dev target/spring-boot-camel-rest-3scale-1.0-SNAPSHOT.jar

You can then access the REST API directly from your Web browser, e.g.:

Running the example in Kubernetes / OpenShift

It is assumed a Kubernetes / OpenShift platform is already running. If not, you can find details how to get started.

The example can be built and deployed using a single goal:

$ mvn fabric8:run

You can use the Kubernetes or OpenShift client tool to inspect the status, e.g.:

  • To list all the running pods:

    $ kubectl get pods
    
  • or on OpenShift:

    $ oc get pods
    
  • Then find the name of the pod that runs this example, and output the logs from the running pod with:

    $ kubectl logs <pod_name>
    
  • or on OpenShift:

    $ oc logs <pod_name>
    

You can also use the Fabric8 Web console to manage the running pods, view logs and much more.

Accessing the REST service

When the example is running, a REST service is available to list users that have called this service. The user information comes from 3scale extensions to autofill API keys.

  • "x-data-threescale-name": "app_ids" for the parameter that represents the application ID.
  • "x-data-threescale-name": "app_keys" or "x-data-threescale-name": "user_keys" for the parameter that represents the application or user key.

Notice: As it depends on your OpenShift setup, the hostname (route) might vary. Verify with oc get routes which hostname is valid for you. Add the -Dfabric8.deploy.createExternalUrls=true option to your Maven commands if you want it to deploy a Route configuration for the service.

The actual endpoint is using the context-path camel-rest-3scale/users and the REST service provides two services:

  • users/greet: to use 3scale API keys to add a user to this service's list of calling users
  • users/list: to list all users that have called the service

You can then access these services from your Web browser, e.g.:

Swagger API

The example provides API documentation of the service using Swagger using the context-path camel-rest-3scale/openapi.json. You can access the API documentation from your Web browser at http://qs-camel-rest-3scale.vagrant.f8/camel-rest-3scale/openapi.json.

More details

You can find more details about running this quickstart on the website. This also includes instructions how to change the Docker image user and registry.

spring-boot-camel-rest-3scale's People

Contributors

johnpoth avatar dhirajsb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.