Christian Posta bio photo

Christian Posta

Chief Architect, cloud application development @ Red Hat, author Microservices for Java Developers, open-source enthusiast, committer @ Apache, Cloud, Integration, Kubernetes, Docker, OpenShift, Fabric8, #blogger

Twitter Google+ LinkedIn Github Stackoverflow

I recently put together a quick Github project to show the Fabric8 HTTP gateway in action. It shows a sample project that you can use to test out the HTTP Gateway. The example/camel/cxf profile that comes with Fabric8 basically does the same thing now.

Fabric8 Gateway

The Fabric8 project -- pronounced fabricate -- is a practical DevOps framework for services running on the JVM. Things like automated deployment and centralized configuration management come out of the box and are consistent regardless of JVM container (or no container -- microservices) you use.

One of the other cool features that Fabric8 gives you out of the box is the ability to dynamically lookup, load balance, and version your services (MQ, REST/http SOAP/http, etc). Clients that live within a "fabric" created by "fabric8" can automatically take advantage of this. Your external clients can too with the Fabric8 Gateway feature. When combined with Apache Camel routes that expose CXF you can get very powerful service discovery using Fabric8.

The sample project comes with three simple REST implementations and deployments that you can use to exercise and test out the Gateway for yourself.

How To

First, start by grabbing Fabric8 or its downstream, supported by Red Hat, cousin: JBoss Fuse.

Start it up:

fabric8-home$  ./bin/fabric8

Or on JBoss Fuse:

fuse-home$  ./bin/fuse

Next, you'll need to build this project:

project-home$  mvn clean install

And navigate to one of the sub-projects in the sample distro (example: beer-service)

Now you'll have to invoke the fabric8-maven-plugin to install the profile into Fabric8/JBoss Fuse. See the fabric8-maven-plugin for more details on what it does and how to set it up:

beer-service$  mvn fabric8:deploy

Now navigate to the web console (http://localhost:8181) and go to the Wiki tab.
You should see your profile there under the loadbalancer group:

picture of profiles

These profiles are the declarative description of what resources need to be deployed to a JVM container. You can read more about Fabric8 Profiles to get a more thorough understanding. In this case, we're deploying some Camel routes and describing its dependencies on some features that provide automatically registering the CXF endpoints into the API registry.

Now create a new container with that profile.

This new container will host your Camel routes that implement this REST service functionality.

picture of profiles

You should have a new beer container:

picture of profiles

Now add a new container and give it the http gateway profile:

picture of profiles

Now you have your beercontainer and your http gateway container:

picture of profiles

Now you can ping the beer service through the gateway at: http://localhost:9000/cxf/beer:

picture of profiles

If you have any questions about this that the screen shots don't capture, please let me know in the comments.
The HTTP Gateway is a very powerful feature of Fabric8. For JBoss Fuse this feature is in tech preview.