Note: A newer revision of this blogpost for apiman 1.2.x can be found here. This version was written for apiman 1.1.x.
This article aims to provide a short guide on how to get API Management capabilities provided by apiman to work with JBoss Fuse, a lightweight, flexible, integration platform that is based on Apache Camel, an implementation of many of the most commonly used enterprise integration patterns (EIP).
Creating API provider in JBoss Fuse
The following few steps should quickly get you started with deploying applications into JBoss Fuse. For demonstration purposes I’m using a sample REST application (quickstart) shipped along with Fuse installation. For more information about developing applications for JBoss Fuse inspect the developer materials and other resources at jboss.org.
To obtain a distribution of JBoss Fuse please visit the JBoss Fuse download page. Installation of JBoss Fuse is very simple, as the only thing you need to do is to unzip the distribution, e.g.
You might also want to enable the default admin user by uncommenting the last line in
<fuse_dir>/etc/users.properties. Without a user configured you won’t be able to log into Fuse management console.
To start Fuse simply execute the following command from
Once JBoss Fuse is loaded proceed by creating a new Fuse Fabric instance. To do that execute
fabric:create command from Fuse CLI:
After Fuse Fabric is up and running, log into Hawt.io management console, it should be by default available at https://localhost:8181. In Fabric perspective, under Containers tabs click on the Create button to open the Create New Container form.
On the Create New Container page fill in the name you wish to use for your container (e.g. my-rest-container) and be sure to select the ‘rest’ profile for it. This will ensure that Fabric pickups the REST Quickstart and deploys it to this container. Finish the operation by hitting the Create and start container button.
The container should start automatically right after it has been created and the REST endpoint should become available. If not, select the appropriate container and hit Start. You can inspect all the APIs deployed to your Fuse Fabric instance by clicking on APIs section under the Services tab. Note the Location field - that’s the base url the for endpoint implementation. We will use it later in the apiman manager.
There is a default user preconfigured so you can verify if the application was successfully deployed. It’s available at
<location>/customerservice/customers/123 (e.g. https://localhost:8182/cxf/crm/customerservice/customers/123)
Configure apiman to manage Fuse endpoint
After completing the installation, start apiman by executing the following command from
Quick public service setup
For demonstration purposes I’ll be creating a Public Service, however in real life you might want to configure different plans, various contracts, etc. Please consult the apiman user guide for more details.
In order to manage APIs in apiman you need to create a new Organization to which your APIs will belong. You can do that easily in apiman manager, typically available at: https://localhost:8080/apimanui.
Once logged into the apiman manager, locate the Organizations sections on the initial page, select Create a New Organization link, provide a name and hit Create Organization button. This will take you to organization details page where you can create a new Service by clicking on New Service button under Services tab:
You will be asked to provide a name and a version for this Service. Once the service is successfully created there are few things remaining before you can publish and start using it. First, you need to provide an implementation base url on the Implementation tab. Use the base URL of the REST Quickstart and save your changes:
Second, you may want to apply some policies to this Public Service. To do that, go to the Policies tab and configure a policy of your choice. I used the Rate Limiting policy to limit usage of this service to 5 per minute:
Now you are all set to make the service public by checking Make this service public under Plans tab, saving the changes and clicking the Publish button (which should be now enabled).
After you have published the service, have a look at the Endpoint tab to look up the URL to be used to invoke this public service:
Testing your setup
Depending on which policy you assinged to the Public Service you might experience different behavior. However, if you followed the tutorial and assigned the Rate Limiting policy after reaching the maximum number of allowed requests you will get an output similar to:
- First request should succeed:
- Executing 5 consecutive requests should fail with
HTTP 429 Too Many Requests: