Spring boot를 이용한 초고속 개발 - Apache Camel
목표
즉시 구현이 완료되지만 이런 느낌

프로젝트 만들기(이번에는 IntelliJ)
시작 화면에서 New Project

Maven 선택



첫 화면

라이브러리 추가
JDK8과 아래 라이브러리 사용
camel-core, camel-spring-boot, spring-boot-starter-web
pom.xml<?xml version="1.0" encoding="UTF-8"?>
<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>hello</groupId>
<artifactId>HelloCamelBoot</artifactId>
<version>1</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<camel-ver>2.15.1</camel-ver>
<spring-boot>1.2.2.RELEASE</spring-boot>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel-ver}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot</artifactId>
<version>${camel-ver}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot}</version>
</dependency>
</dependencies>
</project>
시작용 main 클래스 만들기
자바의 평범한 녀석
뭔가 보이지 않는 구현이 두 가지
@SpringBootApplication
SpringApplication
hello.HelloApppackage hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
*/
@SpringBootApplication
public class HelloApp {
public static void main(String[] args) throws Exception {
System.out.println("-- start! --");
new SpringApplication(HelloApp.class).run();
}
}
시작해보기

움직이지 않았다. main()에 2 행해진 것만으로, Tomcat이 기동한 것 같다.
왼쪽의 빨간색 사각형으로 멈춘다.

Camel의 루트 만들기
이번은 이것으로 구현 종료.
Spring boot + Camel 의 구현은 코드가 적게 살아난다.

@Component 이 중요
hello.route.TimerRoutepackage hello.route;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class TimerRoute extends RouteBuilder{
@Override
public void configure() throws Exception {
from("timer:test?period=1s")
.process(printDate);
}
/** 日時を出力する */
private Processor printDate = new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
System.out.println(new Date());
}
};
}
그리고 기동·정지
초당 표준 출력.
그리고, 멈추면 Graceful shutdown (처리중 데이터가 있으면 처리 완료까지 기다린다) 기능도 작동하고 있다.

조금 수정해
다음 추가
pom.xml <dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-quartz2</artifactId>
<version>${camel-ver}</version>
</dependency>
다음 행 수정/추가
hello.route.TimerRoute // from("timer:test?period=1s")
from("quartz2://myGroup/myTimerName?cron=*+*+10-18+?+*+MON-FRI")
이제 시작!
결과는 거의 동일합니다. 1초간에 1회의 간격으로 일시가 출력된다.
하지만, 월요일부터 금요일의 10시부터 18시 밖에 출력되지 않기 때문에 주의해.
일요일에 이 샘플 움직였지만 움직이지 않는다는 불평은 없음!
Reference
이 문제에 관하여(Spring boot를 이용한 초고속 개발 - Apache Camel), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/daikuro/items/d361f54564e8a59bf631
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
시작 화면에서 New Project

Maven 선택



첫 화면

라이브러리 추가
JDK8과 아래 라이브러리 사용
camel-core, camel-spring-boot, spring-boot-starter-web
pom.xml<?xml version="1.0" encoding="UTF-8"?>
<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>hello</groupId>
<artifactId>HelloCamelBoot</artifactId>
<version>1</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<camel-ver>2.15.1</camel-ver>
<spring-boot>1.2.2.RELEASE</spring-boot>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel-ver}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot</artifactId>
<version>${camel-ver}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot}</version>
</dependency>
</dependencies>
</project>
시작용 main 클래스 만들기
자바의 평범한 녀석
뭔가 보이지 않는 구현이 두 가지
@SpringBootApplication
SpringApplication
hello.HelloApppackage hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
*/
@SpringBootApplication
public class HelloApp {
public static void main(String[] args) throws Exception {
System.out.println("-- start! --");
new SpringApplication(HelloApp.class).run();
}
}
시작해보기

움직이지 않았다. main()에 2 행해진 것만으로, Tomcat이 기동한 것 같다.
왼쪽의 빨간색 사각형으로 멈춘다.

Camel의 루트 만들기
이번은 이것으로 구현 종료.
Spring boot + Camel 의 구현은 코드가 적게 살아난다.

@Component 이 중요
hello.route.TimerRoutepackage hello.route;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class TimerRoute extends RouteBuilder{
@Override
public void configure() throws Exception {
from("timer:test?period=1s")
.process(printDate);
}
/** 日時を出力する */
private Processor printDate = new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
System.out.println(new Date());
}
};
}
그리고 기동·정지
초당 표준 출력.
그리고, 멈추면 Graceful shutdown (처리중 데이터가 있으면 처리 완료까지 기다린다) 기능도 작동하고 있다.

조금 수정해
다음 추가
pom.xml <dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-quartz2</artifactId>
<version>${camel-ver}</version>
</dependency>
다음 행 수정/추가
hello.route.TimerRoute // from("timer:test?period=1s")
from("quartz2://myGroup/myTimerName?cron=*+*+10-18+?+*+MON-FRI")
이제 시작!
결과는 거의 동일합니다. 1초간에 1회의 간격으로 일시가 출력된다.
하지만, 월요일부터 금요일의 10시부터 18시 밖에 출력되지 않기 때문에 주의해.
일요일에 이 샘플 움직였지만 움직이지 않는다는 불평은 없음!
Reference
이 문제에 관하여(Spring boot를 이용한 초고속 개발 - Apache Camel), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/daikuro/items/d361f54564e8a59bf631
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
<?xml version="1.0" encoding="UTF-8"?>
<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>hello</groupId>
<artifactId>HelloCamelBoot</artifactId>
<version>1</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<camel-ver>2.15.1</camel-ver>
<spring-boot>1.2.2.RELEASE</spring-boot>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel-ver}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot</artifactId>
<version>${camel-ver}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot}</version>
</dependency>
</dependencies>
</project>
자바의 평범한 녀석
뭔가 보이지 않는 구현이 두 가지
@SpringBootApplication
SpringApplication
hello.HelloApp
package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
*/
@SpringBootApplication
public class HelloApp {
public static void main(String[] args) throws Exception {
System.out.println("-- start! --");
new SpringApplication(HelloApp.class).run();
}
}
시작해보기

움직이지 않았다. main()에 2 행해진 것만으로, Tomcat이 기동한 것 같다.
왼쪽의 빨간색 사각형으로 멈춘다.

Camel의 루트 만들기
이번은 이것으로 구현 종료.
Spring boot + Camel 의 구현은 코드가 적게 살아난다.

@Component 이 중요
hello.route.TimerRoutepackage hello.route;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class TimerRoute extends RouteBuilder{
@Override
public void configure() throws Exception {
from("timer:test?period=1s")
.process(printDate);
}
/** 日時を出力する */
private Processor printDate = new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
System.out.println(new Date());
}
};
}
그리고 기동·정지
초당 표준 출력.
그리고, 멈추면 Graceful shutdown (처리중 데이터가 있으면 처리 완료까지 기다린다) 기능도 작동하고 있다.

조금 수정해
다음 추가
pom.xml <dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-quartz2</artifactId>
<version>${camel-ver}</version>
</dependency>
다음 행 수정/추가
hello.route.TimerRoute // from("timer:test?period=1s")
from("quartz2://myGroup/myTimerName?cron=*+*+10-18+?+*+MON-FRI")
이제 시작!
결과는 거의 동일합니다. 1초간에 1회의 간격으로 일시가 출력된다.
하지만, 월요일부터 금요일의 10시부터 18시 밖에 출력되지 않기 때문에 주의해.
일요일에 이 샘플 움직였지만 움직이지 않는다는 불평은 없음!
Reference
이 문제에 관하여(Spring boot를 이용한 초고속 개발 - Apache Camel), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/daikuro/items/d361f54564e8a59bf631
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
이번은 이것으로 구현 종료.
Spring boot + Camel 의 구현은 코드가 적게 살아난다.

@Component 이 중요
hello.route.TimerRoute
package hello.route;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class TimerRoute extends RouteBuilder{
@Override
public void configure() throws Exception {
from("timer:test?period=1s")
.process(printDate);
}
/** 日時を出力する */
private Processor printDate = new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
System.out.println(new Date());
}
};
}
그리고 기동·정지
초당 표준 출력.
그리고, 멈추면 Graceful shutdown (처리중 데이터가 있으면 처리 완료까지 기다린다) 기능도 작동하고 있다.

조금 수정해
다음 추가
pom.xml <dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-quartz2</artifactId>
<version>${camel-ver}</version>
</dependency>
다음 행 수정/추가
hello.route.TimerRoute // from("timer:test?period=1s")
from("quartz2://myGroup/myTimerName?cron=*+*+10-18+?+*+MON-FRI")
이제 시작!
결과는 거의 동일합니다. 1초간에 1회의 간격으로 일시가 출력된다.
하지만, 월요일부터 금요일의 10시부터 18시 밖에 출력되지 않기 때문에 주의해.
일요일에 이 샘플 움직였지만 움직이지 않는다는 불평은 없음!
Reference
이 문제에 관하여(Spring boot를 이용한 초고속 개발 - Apache Camel), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/daikuro/items/d361f54564e8a59bf631
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
다음 추가
pom.xml
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-quartz2</artifactId>
<version>${camel-ver}</version>
</dependency>
다음 행 수정/추가
hello.route.TimerRoute
// from("timer:test?period=1s")
from("quartz2://myGroup/myTimerName?cron=*+*+10-18+?+*+MON-FRI")
이제 시작!
결과는 거의 동일합니다. 1초간에 1회의 간격으로 일시가 출력된다.
하지만, 월요일부터 금요일의 10시부터 18시 밖에 출력되지 않기 때문에 주의해.
일요일에 이 샘플 움직였지만 움직이지 않는다는 불평은 없음!
Reference
이 문제에 관하여(Spring boot를 이용한 초고속 개발 - Apache Camel), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/daikuro/items/d361f54564e8a59bf631텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)