Managing Camel Rest Services Using Red Hat 3Scale API Management

DZone 's Guide to

Managing Camel Rest Services Using Red Hat 3Scale API Management

To understand this better, let's take a simple Camel Rest Service example and try integrating that with Red Hat 3Scale.

· DevOps Zone ·
Free Resource

In today's modern world, infrastructure faces a complex challenge of managing user's access to the resources. Software applications and services need to collaborate to accomplish business challenges.

When we think about Red Hat 3Scale, we think about APIs. So what exactly are APIs?

Let's start with a very simple premise: that an API for a business is like an HDMI cable for that business. To be more specific, an API for a business is like that companies HDMI.

Some of you probably might have first encountered an HDMI cable around 10 years back or so or maybe more, because for me when I go to buy the cable for my SMART Television, the salesperson says that it would provide a better picture clarity if I used this kind of cable instead of the standard red, yellow, and white composite cables we all used to use.

Does everyone know or recall the composite red, yellow, and white cable?
And the picture was better, and for the next 10 years or so, HDMI was simply a better way.

HDMI technology is a complex, ever-evolving one. HDMI has had seven major releases over that last 16 years, with at least 35 feature enhancements, from higher resolutions, newer implementations of DVD and CD, to adding Ethernet, and 4K resolution. We use these cables extensively in our offices, connecting our laptops to external monitors. You can yourself see the picture clarity you get from an HDMI cable vs a VGA cable.

So, why am I taking this example?

Every member or a user has to consider these changes, analyze the impact on its own business, and negotiate with partners to meet your needs.

API's are just like these HDMI Cables. As HDMI cables connect different services producing a refined outcome, you can think of APIs as services that are exposed by your business applications. You then need an API Management tool that can provide you with access control, security, rate limits, and API Monetization on top of these exposed API's/Services.

Red Hat 3Scale API Management Is One Such Product From Red Hat

To understand this better, let's take a simple Camel Rest Service example and try integrating that with Red Hat 3Scale.

A simple example of Camel Rest Service can be found here.

Deploying the Camel Service to Openshift:

Now login to your openshift environment and create a new openshift project

oc new-project <name>

Now, you need to navigate to the project home directory for your camel route. In this case camel-example-restful. Then to deploy to openshift just run the mvn fabric8 command seen below.

cd camel-example-restd

$ mvn clean fabric8:deploy 

For this, you can use the Red Hat CodeReady WorkSpaces or the Red Hat CodeReady Studio

Once deployed, check to make sure the Route is deployed, and take a note of the application route as you will see nothing is there. Go ahead and append /camel/hello to it to hit your active rest endpoint


Add Swagger Docs

We need to add the swagger dependency to the pom.xml file.




Add API Mapping to Your Camel Route

Next, we need to tell Camel where to put the swagger docs, a version, and a description for your route. In class SampleCamelRouter.java, add the following,



 .apiProperty("api.title", "Hello World")
 .apiProperty("api.version", "1.0.0"); 

Now, again deploy this camel route with enabling the Swagger docs:

mvn fabric8:deploy

You will see the Swagger Doc for the Camel Services Created,



[vgohel@192 ~]$ curl http://camel-example-restdsl-vgohel-camel.<IP>/camel/api
  "swagger" : "2.0",
  "info" : {
    "version" : "1.0.0",
    "title" : "Hello World"
  "host" : "",
  "schemes" : [ "http" ],
  "paths" : {
    "/hello" : {
      "get" : {
        "operationId" : "say-hello",
        "produces" : [ "text/plain" ],
        "responses" : {
          "200" : {
            "description" : "OK"

Integrating Camel Rest Services with 3Scale API Management

The integration and security of Camel Rest Services will be done by 3Scale. So you will need to have 3Scale and RH-SSO (Red Hat Single Sign-On) deployed setup on openshift. If you haven't set up these, you can refer to this really good article here.

Define Your API's

When you open the 3Scale Admin Console, you will see a page something like below. Select 'New Product'.

api sign ons

For learning purposes, we will define this API Manually. Name your API whatever you would like, similarly add a System Name and description. Select Add

new products

After clicking 'add' you should be navigated to the API's overview page. If not, go to the home page by clicking the Red Hat 3Scale API Management in the upper left-hand corner. Then select your API and finally 'Overview'.

api overview

Create an Application Plan

Towards the bottom of your API Overview Page, there will be a section for Application Plans. These plans allow us to personalize things like rate limiting, monetization, and more. Select the Create Application Plan.

create application plan

create plan

Once you create the application plan you need to publish it. From the Application plan landing page, click publish.

Create a New Method

From there select your newly published Application Plan.

create new method

create new method

Create an Application

From the top menu where it says API: select the drop-down and Select Audience

You should land on a page like this with your user listed. Select your account.

From this next page, you can see all the applications your account is subscribed to. So far, just the Developer app. We need to create a new application for your account is subscribe to based on the API we have. Select 'Create Application'.

account developer

account developer cont.

new application

You will land on your new application's landing page. Success!

To integrate your API with the method, application plan, and application you just created we need to go to the integration section of the 3Scale Management Portal. From the left-hand side menu select Integration → Configuration.


Then, create a new Backend to add to the API created,

add backend

Put your camel base URL (which you can find from the openshift console) as the base URL and put a /path.

The last step is to create a Method Mapping Rule to invoke the Rest Endpoint.

new mapping rule

Your Final Step is to promote the API's, (either in Staging or Production Environments)

APIcast configuration

Click on 'Promote to Staging APICast' and you are done!

You can now access your service using,



curl   "https://vgohel-api-3scale-apicast-staging.<IP>:443/camel/hello?user_key=<user_key>" or using a web browser


I hope this article would help you learn how to integrate services to Red Hat 3Scale API Management. In the next articles to come, I will show you Rate Limiting, Monetization, Security, and more features of 3Scale.

3scale, camel, devops, openapi, openshift, red hat, rest api, swagger, tutorial

Published at DZone with permission of Viral Gohel . See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}