EIP Patterns in Apache Camel using examples
Apache Camel - Table of Contents
File Transfer Using Java DSL Apache Camel Apache Camel Java DSL + Spring Integration Hello World Example Apache Camel Exception Handling Using Simple Example Apache Camel Redelivery policy using example Integrate Apache Camel and ActiveMQ EIP patterns using Apache Camel Apache Camel Tutorial- Integrate Spring Boot+ Apache Camel Apache Camel Tutorial- Integrate with MySQL DB using SQL query Apache Camel + Spring + ActiveMQ + JBoss Fuse Apache Camel EIP - Splitter and Aggregator pattern Apache Camel Unit Testing Apache Camel + Spring + Quartz Hello World Example Camel application deployment on JBoss Fuse Apache Camel + Apache CXF SOAP Webservices Apache Camel + JAX-RS REST Webservice Apache Camel + CXFRS REST Webservice Apache Camel Routing Slip Pattern Apache Camel Dynamic Router Pattern Apache Camel Load Balancer EIP Pattern Apache Camel Interceptors Apache Camel + Kafka Hello World Example Apache Camel - Marshalling/Unmarshalling XML/JSON Data Example Calling and Consuming Webservices using Apache Camel Apache Camel Tutorial - Send SMTP Email Using Gmail Apache Camel Tutorial - SEDA component Hello World Example Apache Camel Tutorial - Idempotent Consumer using MemoryIdempotentRepository and FileIdempotentRepository Spring Boot + Apache Camel JDBC component + MySQL - Hello World Example Spring Boot + Apache Camel SQL component + MySQL - Hello World Example Spring Boot + Apache Camel SQL component + Transaction Management Example
Video
This tutorial is explained in the below Youtube Video.Lets Begin
-
EIP- Splitter
The Splitter from the EIP patterns allows users split a message into a number of pieces and process them individually.
package com.javainuse; import org.apache.camel.builder.RouteBuilder; public class SimpleRouteBuilder extends RouteBuilder { //Split the content of the file into lines and the process it @Override public void configure() throws Exception { from("file:C:/inputFolder").split().tokenize("\n").to("jms:queue:javainuse"); } }
-
EIP- Content
Based Router
The Content-Based Router inspects the content of a message and routes it to another channel based on the content of the message. Using such a router enables the message producer to send messages to a single channel and leave it to the Content-Based Router to inspect messages and route them to the proper destination. This alleviates the sending application from this task and avoids coupling the message producer to specific destination channels.
package com.javainuse; import org.apache.camel.builder.RouteBuilder; public class SimpleRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { from("file:C:/inputFolder").split().tokenize("\n").to("direct:test"); //Content Based routing- Route the message based on the token it contains. from("direct:test"). choice(). when(body().contains("javainuse1")) .to("jms:queue:javainuse1"). when(body().contains("javainuse2")) .to("jms:queue:javainuse2") .when(body().contains("javainuse3")) .to("jms:queue:javainuse3"). otherwise(). to("jms:queue:otherwise"); } } }
- EIP- Message
Filter
A Message Filter is a special form of a Content-Based Router. It examines the message content and passes the