ApacheCamel基础构件

  • 1.CamelContext
  • 2 RouteBuilder
  • 3 Routes
  • 4 URI
  • 5 Filters
  • 6 Choices
  • 7 Processor
  • 8 Endpoints
  • 9 Exchange (Message Exchange)

1.CamelContext

The CamelContext represents a single Camel routing rulebase. You use the CamelContext in a similar way to the Spring ApplicationContext.
See Lifecycle to understand the overall lifecycle of the CamelContext.
CamelContext表示单个Camel路由规则库,其使用方式类似于Spring ApplicationContext。
请参阅生命周期(原链接)以了解CamelContext的整个生命周期(本地连接)。

2 RouteBuilder

The RouteBuilder is a base class which is derived from to create routing rules using the DSL. Instances of RouteBuilder are then added to the CamelContext.
RouteBuilder是一个基类,派生自使用DSL创建路由规则。 然后将RouteBuilder的实例添加到CamelContext中。

3 Routes

Camel supports the definition of routing rules using a Java DSL (domain specific language) which avoids the need for cumbersome XML using a RouteBuilder.
Camel支持使用Java DSL(特定于域的语言)定义路由规则,这避免了使用RouteBuilder对繁琐的XML的需求。
For example a simple route can be created as follows.

RouteBuilder builder = new RouteBuilder() {public void configure() {errorHandler(deadLetterChannel("mock:error"));from("direct:a").to("direct:b");}
};

As you can see from the above Camel uses URIs to wire endpoints together.
Camel使用URI将端点连接在一起

4 URI

(本地API)String formatting——Available as of Camel 2.0 详细参见URIs——API描述
If you have endpoint URIs that accept options and you want to be able to substitute the value, e.g. build the URI by concat the strings together, then you can use the java.lang.String.format method. But in Camel 2.0 we have added two convenient methods in the Java DSL so you can do fromF and toF that uses String formatting to build the URI.
如果您的端点URI接受选项,并且您希望能够替换该值,例如通过将字符串连接在一起来构建URI,然后可以使用java.lang.String.format方法。但是在Camel 2.0中我们在Java DSL中添加了两个方便的方法,因此您可以使用String格式来构建URI。
from(“direct:start”).toF(“file://%s?fileName=%s”, path, name);
fromF(“file://%s?include=%s”, path, pattern).toF(“mock:%s”, result);

5 Filters

You can combine simple routes with filters which can be arbitrary Predicate implementations.
您可以将简单路由与过滤器结合使用,过滤器可以是任意谓词实现。

RouteBuilder builder = new RouteBuilder() {public void configure() {errorHandler(deadLetterChannel("mock:error"));from("direct:a").filter(header("foo").isEqualTo("bar")).to("direct:b");}
};

6 Choices

With a choice you provide a list of predicates and outcomes along with an optional default otherwise clause which is invoked if none of the conditions are met.
通过选择,您可以提供谓词和结果列表以及可选的default otherwise子句,如果不满足任何条件,则调用该子句。

RouteBuilder builder = new RouteBuilder() {public void configure() {errorHandler(deadLetterChannel("mock:error"));from("direct:a").choice().when(header("foo").isEqualTo("bar")).to("direct:b").when(header("foo").isEqualTo("cheese")).to("direct:c").otherwise().to("direct:d");}
};

7 Processor

Using a custom processor
Here is an example of using a custom Processor
以下是使用自定义处理器的示例

myProcessor = new Processor() {public void process(Exchange exchange) {log.debug("Called with exchange: " + exchange);}
};
RouteBuilder builder = new RouteBuilder() {public void configure() {errorHandler(deadLetterChannel("mock:error"));from("direct:a").process(myProcessor);}
};

You can mix and match custom processors with filters and choices.
您可以将自定义处理器与过滤器和选项自由搭配。

RouteBuilder builder = new RouteBuilder() {public void configure() {errorHandler(deadLetterChannel("mock:error"));from("direct:a").filter(header("foo").isEqualTo("bar")).process(myProcessor);}
};

8 Endpoints

Camel supports the Message Endpoint pattern using the Endpoint interface. Endpoints are usually created by a Component and Endpoints are usually referred to in the DSL via their URIs.
Camel使用Endpoint接口支持Message Endpoint模式。 端点通常由组件创建,端点通常通过其URI在DSL中引用。
From an Endpoint you can use the following methods

createProducer() will create a Producer for sending message exchanges to the endpoint
createConsumer() implements the Event Driven Consumer pattern for consuming message exchanges from the endpoint via a Processor when creating a Consumer
createPollingConsumer() implements the Polling Consumer pattern for consuming message exchanges from the endpoint via a PollingConsumer
createProducer()将创建一个Producer,用于向端点发送消息交换
createConsumer()实现了事件驱动的使用者模式,用于在创建使用者时通过处理器消耗来自端点的消息交换
createPollingConsumer()实现Polling Consumer模式,用于通过PollingConsumer消费来自端点的消息交换

9 Exchange (Message Exchange)

To support various message exchange patterns like one way Event Message and Request Reply messages Camel uses an Exchange interface which has a pattern property which can be set to InOnly for an Event Messagewhich has a single inbound Message, or InOut for a Request Reply where there is an inbound and outbound Message.
为了支持各种消息交换模式,例如单向事件消息和请求应答消息,Camel使用具有模式属性的Exchange接口,该属性可以设置为InOnly,用于具有单个入站消息的事件消息,或者InOut用于请求应答,其中 是入站和出站消息。

ApacheCamel基础构件相关推荐

  1. 易观于揚:数据分析是人工智能的基础构件

    整理 | 明明.谷磊 2018年1月16日,全球最大中文 IT 社区 CSDN 在北京举办了" AI 生态赋能2018论坛暨 CSDN AI 新战略发布会".在本次发布会上,即将迈 ...

  2. adonis-rest - 基于AdonisJs的Restful API基础构件

    adonis-rest 基于AdonisJs的Restful API基础构件, AdonisJs中文网: https://adonis-china.org https://github.com/wxs ...

  3. java基础知识点_「Java面试题/知识点精华集」20000+字的Java基础知识篇(2020最新版) !

    " 本文已经收录进我的 79K Star 的 Java 开源项目 JavaGuide:https://github.com/Snailclimb/JavaGuide (「Java学习+面试指 ...

  4. java中override快捷键_【基础回溯1】面试又被 Java 基础难住了?推荐你看看这篇文章。...

    本文已经收录自 https://github.com/Snailclimb/JavaGuide  (59k+ Star):[Java学习+面试指南] 一份涵盖大部分Java程序员所需要掌握的核心知识. ...

  5. java/javaee基础面试问题

    1.面向对象和面向过程的区别对比: 面向对象易维护.易扩展.易复用,由于面向对象继承.封装.多态的特性,可以设计低耦合的系统易于维护,但因为类的实例化开销较大,所以面向过程性能更高,一般性能是最主要的 ...

  6. java面试基础_Java面试基础

    1.面向对象和面向过程的区别? 面向过程:面向过程性能比面向对象高 面向对象:面向对象易维护.易复用.易扩展 2.Java 语言有哪些特点? 简单易学.面向对象(封装,继承,多态).平台无关性( Ja ...

  7. 后端学习 - Java基础

    文章目录 一 基础概念 1 有关Java 2 JVM / JDK / JRE 3 与C++的联系和区别 二 Java语法 1 各类型数据占用空间大小 2 可变长参数 3 静态方法与实例方法 4 重载和 ...

  8. 关于Java基础你不得不会的34个问题

    目录 1. 面向对象和面向过程的区别 2. Java 语言有哪些特点 3. 关于 JVM JDK 和 JRE 最详细通俗的解答 4. Oracle JDK 和 OpenJDK 的对比 5. Java和 ...

  9. Java 基础知识总结(下)-王者笔记《收藏版》

    上一篇 Java基础知识学习总结之(上) 下一篇 Java 集合容器篇面试题  (上) java毕业设计项目<100套>推荐 毕设/私活/大佬必备,一个挣钱的开源前后端分离脚手架 2W字梳 ...

最新文章

  1. beautiful sentences
  2. 许多参数和丢失的信息
  3. php+ksort+返回true,PHP preg_replace函数
  4. mysql 5.7 延迟同步_MySQL5.6升级5.7时出现主从延迟问题排查过程
  5. python正则表达式匹配模式屠夫之桥_小甲鱼零基础入门Python学习视频+全套源码课件 Python视频教程 96讲...
  6. Nginx负载均衡 后端服务器怎么共享Session 问题
  7. 面向计算机视觉的深度学习 | iBooker·ApacheCN
  8. wince怎么刷carplay_carplay wince安装版
  9. 技术架构图-大数据架构
  10. 不写代码,把网站速度优化 10 倍~~
  11. 应届生面试自我介绍该怎么说?
  12. 澳洲ASIC监管-AR牌照
  13. 前端常用标签与注意事项
  14. alanwang[GDOU] 写两个函数,分别求两个整数的最大公约数和最小公倍数,用主函数调用这两个函数,并输出结果。两个整数由键盘输入
  15. 搭建云免流服务器教程,搭建云免流服务器教程
  16. Android仿网易游戏的精美开场动画+动画基础详解
  17. 阿里云centos镜像下载
  18. Linux 性能监控工具命令大全
  19. Innovus/Encounter Floorplan命令合集(二)
  20. python 三维数据绘制等值高线剖面图_Matplotlib中的三维绘图

热门文章

  1. 天地超云高温一体机的耐热秘诀
  2. 数值分析各种算法C语言
  3. 项目工作任务 excel_在Excel中跟踪项目任务
  4. 如何选择适合你的兴趣爱好(七十),表演
  5. Git安装包(win版)
  6. git-for-windows下载地址
  7. 第十四届蓝桥杯(Web 应用开发)模拟赛 1 期-职业院校组-知识点题解
  8. webug 4.0 第一关 显错注入
  9. 白杨SEO:从5118站长工具备案内参发现百度SEO批量建站优化玩法
  10. 国内虚拟主机及国内空间商排名【转】