Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Developing, Testing and Scaling with Apache Camel - UberConf 2015

Apache Camel is an integration framework that allows you to define routing and mediation rules in a number of domain-specific languages. This presentation shows how I used Apache Camel to replace IBM Message Broker on a project. It includes information on how routes were developed using Camel’s Java API and how Camel can be integrated with Spring Boot. It also covers unit, integration and load testing (using Gatling) of these services. Finally, it touches on monitoring with hawtio and New Relic.

5.
What is Apache Camel?
Apache Camel is a versatile open-source
integration framework based on known
Enterprise Integration Patterns.

6.
Enterprise Integration
Why is it necessary?
Businesses need to integration diﬀerent systems
Why a framework?
To allow you to focus on the business logic
Others have done it before, don’t reinvent the wheel
Simpliﬁed testing

18.
public static void main
import org.apache.camel.spring.Main;
/**
* A main class to run the example from your editor.
*/
public final class CamelConsoleMain {
private CamelConsoleMain() {}
public static void main(String[] args) throws Exception {
// Main makes it easier to run a Spring application
Main main = new Main();
// configure the location of the Spring XML file
main.setApplicationContextUri("META-INF/spring/camel-context.xml");
// enable hangup support allows Camel to detect when the JVM is terminated
main.enableHangupSupport();
// run and block until Camel is stopped (or JVM terminated)
main.run();
}
}

24.
James Strachan
Me: “Do you know of any particular guides
about migrating from IBM Message Broker
to Fuse?”
Strachan: “TBH the easiest thing really is to just start using Apache
Camel for this kinda stuﬀ”
Result: Recommended Apache Camel to my client and went to work

25.
Getting Started
Started with a Camel Archetype
Used Java 7
Used Java DSL to deﬁne routes
Development Strategy
1. Write an integration test against existing service
2. Implement the service with Camel; unit test
3. Copy logic from step 1; write integration test

41.
1. Write tests to run against current system. Find the number of
concurrent requests that make it fall over.
2. Run tests against new system and tune accordingly.
3. Throttle requests if there are remote connectivity issues with 3rd
parties. If I needed to throttle requests, I was planning to use
Camel's Throttler.
Gatling Approach

45.
Executing Simulations
Legacy service with 100 users over 60 seconds
mvn test -Dhost=legacy.server:7802 -Dservice=legacy -Dusers=100 -Dramp=60
Local drug service with 100 users over 30 seconds (defaults used)
mvn test -Dusers=100
Results
Legacy service started failing at 400 requests per second (rps)
Local service started throwing errors at 4000/rps

52.
Action!
Don’t be afraid to try new things
Try Apache Camel if you need
Enterprise Integration
Spring Boot Rocks! Try it if you’re
already using Spring
Test, Test, Test, then test some more
Gatling is a great way to ﬁnd our
performance and test with real data