DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • GraphQL vs REST API: Which Is Better for Your Project in 2025?
  • Building a REST Service That Collects HTML Form Data Using Netbeans, Jersey, Apache Tomcat, and Java
  • Spring Boot - How To Use Native SQL Queries | Restful Web Services
  • Testing REST Controller Methods With JUnit 5 [Video]

Trending

  • The Big Data Architecture Blueprint: Core Storage, Integration, and Governance Patterns
  • A Spring Boot App With Half the Startup Time
  • How to Format Articles for DZone
  • Mastering Fluent Bit: Beginners' Guide for Contributing to Our CNCF Project Website
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Calling REST APIs From Camel Routes

Calling REST APIs From Camel Routes

Get your REST API calls squared away!

By 
Vignesh Prabhu user avatar
Vignesh Prabhu
·
Feb. 28, 21 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
15.4K Views

Join the DZone community and get the full member experience.

Join For Free

This article covers calling a REST API from a Camel route. We will try to call the GET endpoint below from a camel route.

http://dummy.restapiexample.com/api/v1/employees


Let's create a Spring Boot Camel microservice.

In the pom.xml of the microservice, add the dependency below:

XML
 




x


 
1
<dependency>
2
    <groupId>org.apache.camel.springboot</groupId>
3
    <artifactId>camel-http-starter</artifactId>
4
    <version>3.8.0</version>
5
</dependency>



Configuring the REST Client Route in the Microservice

restConfiguration() is used to configure the host and the port.

The route is configured to run every 10 secs and call the REST API endpoint using the GET method. 

Java
 




xxxxxxxxxx
1
18


 
1
package com.vignesh.cameldemob.route.b;
2

          
3
import org.apache.camel.builder.RouteBuilder;
4
import org.springframework.stereotype.Component;
5

          
6
@Component
7
public class RestAPIClientRoute extends RouteBuilder {
8

          
9
    @Override
10
    public void configure() throws Exception {
11
        restConfiguration().host("dummy.restapiexample.com").port(80);
12

          
13
        from("timer:rest-client?period=10s")
14
                .to("rest:get:/api/v1/employees")
15
                .log("${body}");
16
    }
17
}
18

          


Testing

Start the application. You can see that the timer is triggered every 10 secs, and the REST API endpoint is called.

REST Web Protocols

Opinions expressed by DZone contributors are their own.

Related

  • GraphQL vs REST API: Which Is Better for Your Project in 2025?
  • Building a REST Service That Collects HTML Form Data Using Netbeans, Jersey, Apache Tomcat, and Java
  • Spring Boot - How To Use Native SQL Queries | Restful Web Services
  • Testing REST Controller Methods With JUnit 5 [Video]

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook