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

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

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

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

  • Dropwizard vs. Micronaut: Unpacking the Best Framework for Microservices
  • IoT and Cybersecurity: Addressing Data Privacy and Security Challenges
  • DGS GraphQL and Spring Boot
  • Building Resilient Identity Systems: Lessons from Securing Billions of Authentication Requests
  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!