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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • 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]
  • Update User Details in API Test Client Using REST Assured [Video]

Trending

  • A Guide to Container Runtimes
  • Breaking Bottlenecks: Applying the Theory of Constraints to Software Development
  • Unlocking the Benefits of a Private API in AWS API Gateway
  • Google Cloud Document AI Basics
  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
14.6K 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

  • 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]
  • Update User Details in API Test Client Using REST Assured [Video]

Partner Resources

×

Comments
Oops! Something Went Wrong

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

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!