Integrate Apache Camel and ActiveMQ
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 EIP - Splitter and Aggregator pattern Apache Camel Unit Testing Apache Camel + Spring + Quartz Hello World Example Camel application deployment on JBoss Fuse Apache Camel + JAX-RS REST Webservice Apache Camel + CXFRS REST Webservice Apache Camel Routing Slip EIP Pattern Apache Camel Dynamic Router Pattern Apache Camel Load Balancer EIP Pattern Apache Camel Interceptors Calling and Consuming Webservices using Apache Camel Apache Camel + Kafka Hello World Example Apache Camel - Marshalling/Unmarshalling XML/JSON Data Example Apache Camel Tutorial - Send SMTP Email Using Gmail Apache Camel Tutorial - SEDA component Hello World Example Spring Boot + Apache Camel + RabbitMQ - 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
In the previous example we created a simple example to copy file from one folder to another. In this example we will copy the contents of a file to ActiveMQ. We will also be making use of an Enterprise Integration Pattern(EIP) here to split the file line by line and then send it to the queue. In my next tutorial have explained the EIPs in detail.We will create Eclipse maven project as follows-

Our pom file will be as follows-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.javainuse</groupId> <artifactId>camel-activemq-dsl</artifactId> <version>0.0.1-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-core</artifactId> <version>2.13.0</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jms</artifactId> <version>2.14.1</version> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-camel</artifactId> <version>5.7.0</version> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-broker</artifactId> <version>5.10.1</version> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-client</artifactId> <version>5.10.1</version> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-pool</artifactId> <version>5.10.1</version> </dependency> </dependencies> </project>Next we create a class to construct a Camel Route. A Route is like a instruction definition to Camel on how to move your messages from one point to another. We are going to create SimpleRouteBuilder.java file that will move files from c://inputFolder to ActiveMQ. Here we are making use of the JMS component which we will define in the main class later.
package com.javainuse; import org.apache.camel.builder.RouteBuilder; public class SimpleRouteBuilder extends RouteBuilder { //configure route for jms component @Override public void configure() throws Exception { from("file:C:/inputFolder").split().tokenize("\n").to("jms:queue:javainuse"); } }