apache came 初识

  1. 简介
    Camel框架的核心是一个路由引擎,或者更确切地说是一个路由引擎构建器。它允许您定义自己的路由规则,决定从哪个源接收消息,并确定如何处理这些消息并将其发送到其他目标。
    参考:https://www.jianshu.com/p/68aba8d09a89

  2. 实践
    file to file

pom:


4.0.0

org.springframework.boot
spring-boot-starter-parent
2.6.6


com.example
camel-demo
0.0.1-SNAPSHOT
camel-demo
Camel Demo project for Spring Boot

<java.version>1.8</java.version>



org.springframework.boot
spring-boot-starter-actuator


org.springframework.boot
spring-boot-starter-web


org.apache.camel.springboot
camel-spring-boot-starter
3.10.0

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<scope>test</scope>
	</dependency>
</dependencies>

<build>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
		</plugin>
	</plugins>
</build>

test类:
package com.example.cameldemo.test;

import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;

/**

  • @Classname Test
    */
    public class Test {
    public static void main(String[] args) throws Exception {
    CamelContext contest = new DefaultCamelContext();
    contest.addRoutes(new RouteBuilder() {
    @Override
    public void configure() throws Exception {
    from("file:data/in?noop=true")
    .to("file:data/out");
    }
    });
    contest.start();;
    Thread.sleep(10000);

     contest.stop();
    

    }

}

posted @ 2022-04-08 18:47  谁在逆水行舟  阅读(92)  评论(0编辑  收藏  举报