简介
Apache Camel是一个轻量级应用集成开发框架,专注于简化集成应用集成开发。
名字由来 https://camel.apache.org/manual/latest/faq/why-the-name-camel.html 。Camel是EIP企业应用架构模式的实现。使用Camel开发程序时,通过自定义的https://camel.apache.org/manual/dsl.html 语法来定义代码流程,从而简化集成对接过程,提升开发效率。
通常大家会拿Apache Camel和老牌的ESB产品比如MuleESB、Spring Intergration进行对比。Apache Camel本身不是一个完整的产品,自身定位还是开发框架,从这个层面上讲和Spring Intergration类似,不同的的是各自实现的复杂度不通。相比Spring Intergration来说,Camel的DSL语法非常易读,很简单;同时Camel的组件比Spring Intergration丰富太多了。相对于重量级的ESB产品来说,Camel提供的核心库很少,结合Spring框架就可以快速上手。
特性介绍
Apache Camel通过对相同业务数据的抽象处理,形成标准的数据处理模式,从而可以使用配置的方式快速实现业务功能。典型的业务场景如下:
● 接口对接 - 接口报文转换 比如json格式/内容
● 协议转换 - 不同协议的接口适配 比如web service接口转rest,tcp接口转rest等
● 数据对接 - etl数据清洗
在应用架构总通常用于和外部系统进行集成对接。特别适合在大的金融行业、电信行业等系统特别复杂的场景下做系统对接集成工作。对于小型的应用集成项目很难体现出Camel的应用优势,大家可以根据自身的业务应用需求来灵活选择。
Apache Camel具备如下特点
● 使用基于SEDA处理模型的高度可伸缩的企业服务器
● 支持REST API
● 强大的基于EIP模式的事件路由机制
● 动态、声明性的,基于内容和基于规则的路由选项
● 易扩展
● 可以结合Spring boot使用
Camel整体架构
Camel整体围绕路由引擎,通过路由规则来规范消息的路由和处理方式。路由是通过Camel DSL(Domain Specific Language)定义。Processor用于处理不同Endpoints间的消息处理。Components是Camel的扩展点,Component组件提供统一的endpoint接口,用于扩展Camel和外部系统的连接。
Camel DSL支持Java DSL和XML两种方式。Camel DSL XML方式的Camel路由配置示例如下所示:
how are you?
Camel DSL最外层的跟节点CamelContext定义。Camel Context是运行时容器,camel运行的所有上下文环境都在camel context对象中封装,用于控制route的执行流程和执行上下文。每一个Cmael Context由以下几大块组成:
Service | 功能描述 |
---|---|
Components | Contains the components used. |
Endpoints | Contains the endpoints that have been used. |
Routes | Routes用于定义路由规则 |
Data formats | Contains the loaded data formats. |
Languages | Contains the loaded languages. |
Type converters | 类型转换处理配置 |
Registry | 用于管理注册的Java Bean |
camel框架中AbstractCamelContext中可以看到该类定义,可以通过源码来加深理解。
private final List endpointStrategies;
private final GlobalEndpointConfiguration globalEndpointConfiguration;
private final Map components;
private final Set routes;
private final List servicesToStop;
private final List bootstraps;
private final List startupListeners;
private final DeferServiceStartupListener deferStartupListener;
private final Map languages;
private final Map dataformats;
private final List lifecycleStrategies;
private final ThreadLocal isStartingRoutes;
private final ThreadLocal isSetupRoutes;
private final Map factories;
private final Map bootstrapFactories;
private volatile FactoryFinder bootstrapFactoryFinder;
private volatile ConfigurerResolver bootstrapConfigurerResolver;
private final Map routeServices;
private final Map suspendedRouteServices;
private final RouteController internalRouteController;
private final InternalRouteStartupManager internalRouteStartupManager;
private volatile DeferServiceFactory deferServiceFactory;
private volatile AnnotationBasedProcessorFactory annotationBasedProcessorFactory;
private final List routeStartupOrder;
private final StopWatch stopWatch;
private final Map, Object> extensions;
private Set logListeners;
private final ThreadLocal> componentsInCreation;
private volatile Registry registry;
......
camel context中定义的各个要素通过ROUTING ENGINE来进行控制,路由(Routes)是camel中的一个核心的基础抽象,路由简单来讲就是一系列处理器的链路。可以用于动态决定消息的处理逻辑。
每一个route都有一个唯一的id,可以用于监控、查看日志、debug、控制route的启动、停止等。每一个route都是一个完整的业务逻辑处理单元,每一个route都要有明确的输入message,因此route必须和一个输入的endpoint进行绑定。
route中的每一个处理链路,通过endpoint概念来抽象消息接收和发送的通道。
在camel中,通过uri定义endpoint例如 file:data/inbox?delay=5000。实时运行的过程中camel通过endpoint的定义,来选择对应的组件(component)以及运行参数来动态执行对应的业务流程。组件(component) 是和endppint的URI中的组件名称关联,并扮演一个创建工厂的角色,创建对应的endpoint。例如下图中scheme file对应的就是FileComponent,FileCompent根据url的其他参数创建FileEndpoint。
endpoint接着会创建运行需要的exchange对象,以及consumer,最终调用processor进行业务逻辑的处理。再学习的过程中可以打开hawtio监控可以看到endpoint关联的对象如下图所示。
在route中也可以直接调用processor,下面是process直接调用的基本语法。
处理器processor用于处理输入的exchange消息,路由中的流程定义,实际上就是processor的调用流程。
一个路由开始于一个能够处理初始exchange消息的消费者开始。在每个处理器步骤中,前一步骤的输出消息是下一步骤的输入消息。在许多情况下,处理器不设置out消息,这种情况下,In消息被重用。在路由结束时,交换的MEP决定是否需要将回复发送回路由的调用者。如果MEP为InOnly,则不会发送回复。如果是InOut,Camel将从最后一步获取out消息并将其返回。
通过endpoint调用processor相对直接调用process又有什么区别呢?主要是应用场景的差别,我们打开FileEndpoint源码, 从其中可以看到,和调用普通的processor最大的区别是配置参数,可以很方便配置化使用。最终的调用的服务使用上依然是使用的process。
@UriEndpoint(
firstVersion = "1.0.0",
scheme = "file",
title = "File",
syntax = "file:directoryName",
category = {Category.FILE, Category.CORE}
)
public class FileEndpoint extends GenericFileEndpoint {
public FileEndpoint(String endpointUri, Component component) {
super(endpointUri, component);
}
public FileConsumer createConsumer(Processor processor) throws Exception {
}
public PollingConsumer createPollingConsumer() throws Exception {
}
public GenericFileProducer createProducer() throws Exception {
}
}
基本术语详解
Routes/Route
路由是Camel的核心抽象概念,通过一个完整的路由定义消息处理和执行的流程;在消息应用中使用路由有很多种原因,通常用于解耦的客户端和服务器端,生产者和消费者。
Camel中的每个路由都有一个惟一标识,用于日志记录、调试、跟踪,以及启动和停止路由等操作。路由也有一个输入消息源,所以每个路由有效地绑定到了输入的Endpoint。
Camel消息模型
消息模型是系统设计的关键要素,可以类比于常见的tcp/ip、sip、pop3等协议一样。在Camel整体的数据交换体系里,主要通过org.apache.camel.Message以及org.apache.camel.Exchange两个抽象类来对Camel的数据通信进行抽象。
producer是Camel中的一个抽象概念,producer可以创建和发送消息到一个Endpoint的主体。消息发送到
Endpoint时,producer创建一个Endpoint,同时将相关的数据填充到对应的Exchange中。
consumer是接收producer产生的message的服务,并将消息包装为exchange,然后还可将消息交给processor进行处理。consumer要创建新的exchange,consumer将使用该exchange包装message。然后使用processor来启动exchange路由,并在Camel路由引擎中流转。
在Camel中有两种consumer:
○ event-driven consumers:事件驱动的消费者
○ polling consumers:轮询消费
下图中可以看到Apache Camel的消息处理的角色,在这个过程中大家注意下这里面的producer和sonsumer和我们经典意义的pub/sub模型是有点差别的。这里面的producer和sonsumer可以pub/sub方式消费
,也泛指消息的接收和发送。
Message
Message是系统间消息通信的实体,用于规范发送和接收者的报文规范。
消息的主要组成包括消息头、消息体以及可选的消息附件。
每一个消息都有一个消息ID,用于唯一的表识一个消息。Headers用于标明消息的基本信息,比如发送者Id、认证信息、编码信息等。Header是 Map
附件通常用于web service或者邮件组件中的附加信息传输。当然你也可以扩展附件用于其他消息通信用途,比如记录web service接口的附加说明等。
body是消息的载体,Object类型,各个组件在使用的时候根据自身的业务处理需要来定义Object对象的具体实现。
falult flag ?
Message接口的具体定义见org.apache.camel.Message, 下图中也摘录一份供大家学习使用。从下图中可以看到Message还定义了一些常见的方法比如对象copy、获取exchange等。
package org.apache.camel;
import java.util.Map;
import java.util.function.Supplier;
public interface Message {
String getMessageId();
void setMessageId(String messageId);
Exchange getExchange();
Object getHeader(String name);
Object getHeader(String name, Object defaultValue);
Object getHeader(String name, Supplier
Exchange
Exchange用于消息交换,exchange中定义了消息交互的模式Message Exchange Patterns(MEP)以及输入、输出消息。
- Exchange id用于唯一表示一个exchange实体
- MEP 用于表明消息交互的类型是InOnly还是InOut消息。InOnly消息包含一个In Message, InOut消息既包括InMessage、同时又包括OutMessage。
- Exception用于保存routing过程中的错误消息
- Properties类似Message中的Headers信息,用于存储整个路由过程中的全局信息。比如全局的traceId、日志信息等。
- In Message是输入消息,包含了请求信息。
- Out Message请求的响应信息,只有当MEP是InOut模式时,该消息才存在。
Excahneg接口的具体定义见org.apache.camel.Message, 下图中也摘录一份供大家学习使用。从下图中可以看到Message还定义了一些常见的方法比如对象copy、获取exchange等。
package org.apache.camel;
import java.util.Map;
import org.apache.camel.spi.UnitOfWork;
import org.apache.camel.spi.annotations.ConstantProvider;
@ConstantProvider("org.apache.camel.ExchangeConstantProvider")
public interface Exchange {
String AUTHENTICATION = "CamelAuthentication";
String AUTHENTICATION_FAILURE_POLICY_ID = "CamelAuthenticationFailurePolicyId";
/** @deprecated */
@Deprecated
String ACCEPT_CONTENT_TYPE = "CamelAcceptContentType";
String AGGREGATED_SIZE = "CamelAggregatedSize";
String AGGREGATED_TIMEOUT = "CamelAggregatedTimeout";
String AGGREGATED_COMPLETED_BY = "CamelAggregatedCompletedBy";
String AGGREGATED_CORRELATION_KEY = "CamelAggregatedCorrelationKey";
String AGGREGATED_COLLECTION_GUARD = "CamelAggregatedCollectionGuard";
String AGGREGATION_STRATEGY = "CamelAggregationStrategy";
String AGGREGATION_COMPLETE_CURRENT_GROUP = "CamelAggregationCompleteCurrentGroup";
String AGGREGATION_COMPLETE_ALL_GROUPS = "CamelAggregationCompleteAllGroups";
String AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE = "CamelAggregationCompleteAllGroupsInclusive";
String ASYNC_WAIT = "CamelAsyncWait";
String BATCH_INDEX = "CamelBatchIndex";
String BATCH_SIZE = "CamelBatchSize";
String BATCH_COMPLETE = "CamelBatchComplete";
String BEAN_METHOD_NAME = "CamelBeanMethodName";
String BINDING = "CamelBinding";
String BREADCRUMB_ID = "breadcrumbId";
String CHARSET_NAME = "CamelCharsetName";
String CIRCUIT_BREAKER_STATE = "CamelCircuitBreakerState";
/** @deprecated */
@Deprecated
String CREATED_TIMESTAMP = "CamelCreatedTimestamp";
String CLAIM_CHECK_REPOSITORY = "CamelClaimCheckRepository";
String CONTENT_ENCODING = "Content-Encoding";
String CONTENT_LENGTH = "Content-Length";
String CONTENT_TYPE = "Content-Type";
String COOKIE_HANDLER = "CamelCookieHandler";
String CORRELATION_ID = "CamelCorrelationId";
String DATASET_INDEX = "CamelDataSetIndex";
String DEFAULT_CHARSET_PROPERTY = "org.apache.camel.default.charset";
String DESTINATION_OVERRIDE_URL = "CamelDestinationOverrideUrl";
String DISABLE_HTTP_STREAM_CACHE = "CamelDisableHttpStreamCache";
String DUPLICATE_MESSAGE = "CamelDuplicateMessage";
String DOCUMENT_BUILDER_FACTORY = "CamelDocumentBuilderFactory";
String EXCEPTION_CAUGHT = "CamelExceptionCaught";
String EXCEPTION_HANDLED = "CamelExceptionHandled";
String EVALUATE_EXPRESSION_RESULT = "CamelEvaluateExpressionResult";
String ERRORHANDLER_CIRCUIT_DETECTED = "CamelFErrorHandlerCircuitDetected";
/** @deprecated */
@Deprecated
String ERRORHANDLER_HANDLED = "CamelErrorHandlerHandled";
/** @deprecated */
@Deprecated
String EXTERNAL_REDELIVERED = "CamelExternalRedelivered";
String FAILURE_HANDLED = "CamelFailureHandled";
String FAILURE_ENDPOINT = "CamelFailureEndpoint";
String FAILURE_ROUTE_ID = "CamelFailureRouteId";
String FATAL_FALLBACK_ERROR_HANDLER = "CamelFatalFallbackErrorHandler";
String FILE_CONTENT_TYPE = "CamelFileContentType";
String FILE_LOCAL_WORK_PATH = "CamelFileLocalWorkPath";
String FILE_NAME = "CamelFileName";
String FILE_NAME_ONLY = "CamelFileNameOnly";
String FILE_NAME_PRODUCED = "CamelFileNameProduced";
String FILE_NAME_CONSUMED = "CamelFileNameConsumed";
String FILE_PATH = "CamelFilePath";
String FILE_PARENT = "CamelFileParent";
String FILE_LAST_MODIFIED = "CamelFileLastModified";
String FILE_LENGTH = "CamelFileLength";
String FILE_LOCK_FILE_ACQUIRED = "CamelFileLockFileAcquired";
String FILE_LOCK_FILE_NAME = "CamelFileLockFileName";
String FILE_LOCK_EXCLUSIVE_LOCK = "CamelFileLockExclusiveLock";
String FILE_LOCK_RANDOM_ACCESS_FILE = "CamelFileLockRandomAccessFile";
String FILE_LOCK_CHANNEL_FILE = "CamelFileLockChannelFile";
String FILTER_MATCHED = "CamelFilterMatched";
String FILTER_NON_XML_CHARS = "CamelFilterNonXmlChars";
String GROUPED_EXCHANGE = "CamelGroupedExchange";
String HTTP_SCHEME = "CamelHttpScheme";
String HTTP_HOST = "CamelHttpHost";
String HTTP_PORT = "CamelHttpPort";
String HTTP_BASE_URI = "CamelHttpBaseUri";
String HTTP_CHARACTER_ENCODING = "CamelHttpCharacterEncoding";
String HTTP_METHOD = "CamelHttpMethod";
String HTTP_PATH = "CamelHttpPath";
String HTTP_PROTOCOL_VERSION = "CamelHttpProtocolVersion";
String HTTP_QUERY = "CamelHttpQuery";
String HTTP_RAW_QUERY = "CamelHttpRawQuery";
String HTTP_RESPONSE_CODE = "CamelHttpResponseCode";
String HTTP_RESPONSE_TEXT = "CamelHttpResponseText";
String HTTP_URI = "CamelHttpUri";
String HTTP_URL = "CamelHttpUrl";
String HTTP_CHUNKED = "CamelHttpChunked";
String HTTP_SERVLET_REQUEST = "CamelHttpServletRequest";
String HTTP_SERVLET_RESPONSE = "CamelHttpServletResponse";
String INTERCEPTED_ENDPOINT = "CamelInterceptedEndpoint";
String INTERCEPT_SEND_TO_ENDPOINT_WHEN_MATCHED = "CamelInterceptSendToEndpointWhenMatched";
/** @deprecated */
@Deprecated
String INTERRUPTED = "CamelInterrupted";
String LANGUAGE_SCRIPT = "CamelLanguageScript";
String LOG_DEBUG_BODY_MAX_CHARS = "CamelLogDebugBodyMaxChars";
String LOG_DEBUG_BODY_STREAMS = "CamelLogDebugStreams";
String LOG_EIP_NAME = "CamelLogEipName";
String LOOP_INDEX = "CamelLoopIndex";
String LOOP_SIZE = "CamelLoopSize";
String SAGA_LONG_RUNNING_ACTION = "Long-Running-Action";
String MAXIMUM_CACHE_POOL_SIZE = "CamelMaximumCachePoolSize";
String MAXIMUM_ENDPOINT_CACHE_SIZE = "CamelMaximumEndpointCacheSize";
String MAXIMUM_SIMPLE_CACHE_SIZE = "CamelMaximumSimpleCacheSize";
String MAXIMUM_TRANSFORMER_CACHE_SIZE = "CamelMaximumTransformerCacheSize";
String MAXIMUM_VALIDATOR_CACHE_SIZE = "CamelMaximumValidatorCacheSize";
String MESSAGE_HISTORY = "CamelMessageHistory";
String MESSAGE_HISTORY_HEADER_FORMAT = "CamelMessageHistoryHeaderFormat";
String MESSAGE_HISTORY_OUTPUT_FORMAT = "CamelMessageHistoryOutputFormat";
String MULTICAST_INDEX = "CamelMulticastIndex";
String MULTICAST_COMPLETE = "CamelMulticastComplete";
/** @deprecated */
@Deprecated
String NOTIFY_EVENT = "CamelNotifyEvent";
String ON_COMPLETION = "CamelOnCompletion";
String OVERRULE_FILE_NAME = "CamelOverruleFileName";
String PARENT_UNIT_OF_WORK = "CamelParentUnitOfWork";
String STREAM_CACHE_UNIT_OF_WORK = "CamelStreamCacheUnitOfWork";
String RECIPIENT_LIST_ENDPOINT = "CamelRecipientListEndpoint";
String RECEIVED_TIMESTAMP = "CamelReceivedTimestamp";
String REDELIVERED = "CamelRedelivered";
String REDELIVERY_COUNTER = "CamelRedeliveryCounter";
String REDELIVERY_MAX_COUNTER = "CamelRedeliveryMaxCounter";
/** @deprecated */
@Deprecated
String REDELIVERY_EXHAUSTED = "CamelRedeliveryExhausted";
String REDELIVERY_DELAY = "CamelRedeliveryDelay";
String REST_HTTP_URI = "CamelRestHttpUri";
String REST_HTTP_QUERY = "CamelRestHttpQuery";
/** @deprecated */
@Deprecated
String ROLLBACK_ONLY = "CamelRollbackOnly";
/** @deprecated */
@Deprecated
String ROLLBACK_ONLY_LAST = "CamelRollbackOnlyLast";
/** @deprecated */
@Deprecated
String ROUTE_STOP = "CamelRouteStop";
String REUSE_SCRIPT_ENGINE = "CamelReuseScripteEngine";
String COMPILE_SCRIPT = "CamelCompileScript";
String SAXPARSER_FACTORY = "CamelSAXParserFactory";
String SCHEDULER_POLLED_MESSAGES = "CamelSchedulerPolledMessages";
String SOAP_ACTION = "CamelSoapAction";
String SKIP_GZIP_ENCODING = "CamelSkipGzipEncoding";
String SKIP_WWW_FORM_URLENCODED = "CamelSkipWwwFormUrlEncoding";
String SLIP_ENDPOINT = "CamelSlipEndpoint";
String SLIP_PRODUCER = "CamelSlipProducer";
String SPLIT_INDEX = "CamelSplitIndex";
String SPLIT_COMPLETE = "CamelSplitComplete";
String SPLIT_SIZE = "CamelSplitSize";
String STEP_ID = "CamelStepId";
String TIMER_COUNTER = "CamelTimerCounter";
String TIMER_FIRED_TIME = "CamelTimerFiredTime";
String TIMER_NAME = "CamelTimerName";
String TIMER_PERIOD = "CamelTimerPeriod";
String TIMER_TIME = "CamelTimerTime";
String TO_ENDPOINT = "CamelToEndpoint";
String TRACE_EVENT = "CamelTraceEvent";
String TRACE_EVENT_NODE_ID = "CamelTraceEventNodeId";
String TRACE_EVENT_TIMESTAMP = "CamelTraceEventTimestamp";
String TRACE_EVENT_EXCHANGE = "CamelTraceEventExchange";
String TRACING_HEADER_FORMAT = "CamelTracingHeaderFormat";
String TRACING_OUTPUT_FORMAT = "CamelTracingOutputFormat";
String TRY_ROUTE_BLOCK = "TryRouteBlock";
String TRANSFER_ENCODING = "Transfer-Encoding";
String UNIT_OF_WORK_EXHAUSTED = "CamelUnitOfWorkExhausted";
/** @deprecated */
@Deprecated
String UNIT_OF_WORK_PROCESS_SYNC = "CamelUnitOfWorkProcessSync";
String XSLT_FILE_NAME = "CamelXsltFileName";
String XSLT_ERROR = "CamelXsltError";
String XSLT_FATAL_ERROR = "CamelXsltFatalError";
String XSLT_WARNING = "CamelXsltWarning";
T adapt(Class type);
ExchangePattern getPattern();
void setPattern(ExchangePattern pattern);
Object getProperty(String name);
/** @deprecated */
@Deprecated
Object getProperty(String name, Object defaultValue);
T getProperty(String name, Class type);
T getProperty(String name, Object defaultValue, Class type);
void setProperty(String name, Object value);
Object removeProperty(String name);
boolean removeProperties(String pattern);
boolean removeProperties(String pattern, String... excludePatterns);
Map getProperties();
boolean hasProperties();
Message getIn();
Message getMessage();
T getMessage(Class type);
void setMessage(Message message);
T getIn(Class type);
void setIn(Message in);
/** @deprecated */
@Deprecated
Message getOut();
/** @deprecated */
@Deprecated
T getOut(Class type);
/** @deprecated */
@Deprecated
boolean hasOut();
/** @deprecated */
@Deprecated
void setOut(Message out);
Exception getException();
T getException(Class type);
void setException(Throwable t);
boolean isFailed();
boolean isTransacted();
boolean isRouteStop();
void setRouteStop(boolean routeStop);
boolean isExternalRedelivered();
boolean isRollbackOnly();
void setRollbackOnly(boolean rollbackOnly);
boolean isRollbackOnlyLast();
void setRollbackOnlyLast(boolean rollbackOnlyLast);
CamelContext getContext();
Exchange copy();
Endpoint getFromEndpoint();
String getFromRouteId();
UnitOfWork getUnitOfWork();
String getExchangeId();
void setExchangeId(String id);
long getCreated();
}
Message & Exchange区别
The exchange is the same for the entire lifecycle of routing, but the messages can change, for instance, if messages are transformed from one format to another.
数据转换
数据转换(Data Transformation)可以分为两种类型:
- 数据格式转换 Data format transformation - 消息体的数据格式从一种转换成另外一种,例如CSV格式转换成XML格式
- 数据类型转换 Data type transformation - 消息体的数据类型从一种转换成另外一种,例如 java.lang.String 转换成 javax.jms.TextMessage
Camel 对数据格式和数据类型的转换有几种方式:
- Data formats - XML, JSON ...
- Expression - Languages
- Java - Processor, Bean, Content Enricher
- Templates - XSLT, Apache Velocity ...
data formats
data formats用于处理数据格式转换,不涉及数据内容或者结构的改变。Data formats 在 Camel 里以可插拔的转换器形式存在。每个 data format 实现了接口 org.apache.camel.spi.DataFormat
并包含两个方法:
-
marshal
- 把一个 Message 编译成常见的数据格式,例如编译java对象成 XML, CSV, Json 等 -
unmarshal
- 反编译,把常见数据格式转换成 Message
{"people": ${body}}
例如对如下的xml请求进行转换处理:
jjj
gf
22
g1f
221
转换的对象中有数组时转换需要定义转换对象类型POJO
JacksonXML转换时需要定义对应的转换POJO对象,通过注解方式映射@JsonRootName等
{"msg": "hello3"}
Camel中支持的数据格式类型包括以下数据格式:
Data Format | Level | Description |
---|---|---|
Any23 | Stable | Extract RDF data from HTML documents. |
ASN.1 File | Stable | Encode and decode data structures using Abstract Syntax Notation One (ASN.1). |
Avro | Stable | Serialize and deserialize messages using Apache Avro binary data format. |
Avro Jackson | Stable | Marshal POJOs to Avro and back using Jackson. |
Barcode | Stable | Transform strings to various 1D/2D barcode bitmap formats and back. |
Base64 | Stable | Encode and decode data using Base64. |
Bindy | Stable | Marshal and unmarshal between POJOs and key-value pair (KVP) format using Camel Bindy |
CBOR | Stable | Unmarshal a CBOR payload to POJO and back. |
Crypto | Stable | Encrypt and decrypt messages using Java Cryptography Extension (JCE). |
CSV | Stable | Handle CSV (Comma Separated Values) payloads. |
FHIR JSon | Stable | Marshall and unmarshall FHIR objects to/from JSON. |
FHIR XML | Stable | Marshall and unmarshall FHIR objects to/from XML. |
Flatpack | Stable | Marshal and unmarshal Java lists and maps to/from flat files (such as CSV, delimited, or fixed length formats) using Flatpack library. |
Grok | Stable | Unmarshal unstructured data to objects using Logstash based Grok patterns. |
GZip Deflater | Stable | Compress and decompress messages using java.util.zip.GZIPStream. |
HL7 | Stable | Marshal and unmarshal HL7 (Health Care) model objects using the HL7 MLLP codec. |
iCal | Stable | Marshal and unmarshal iCal (.ics) documents to/from model objects. |
Jackson XML | Stable | Unmarshal an XML payloads to POJOs and back using XMLMapper extension of Jackson. |
JAXB | Stable | Unmarshal XML payloads to POJOs and back using JAXB2 XML marshalling standard. |
JSON Fastjson | Stable | Marshal POJOs to JSON and back using Fastjson |
JSON Gson | Stable | Marshal POJOs to JSON and back using Gson |
JSON Jackson | Stable | Marshal POJOs to JSON and back using Jackson |
JSON Johnzon | Stable | Marshal POJOs to JSON and back using Johnzon |
JSON JSON-B | Stable | Marshal POJOs to JSON and back using JSON-B. |
JSON XStream | Stable | Marshal POJOs to JSON and back using XStream |
JSonApi | Stable | Marshal and unmarshal JSON:API resources using JSONAPI-Converter library. |
LZF Deflate Compression | Stable | Compress and decompress streams using LZF deflate algorithm. |
MIME Multipart | Stable | Marshal Camel messages with attachments into MIME-Multipart messages and back. |
PGP | Stable | Encrypt and decrypt messages using Java Cryptographic Extension (JCE) and PGP. |
Protobuf | Stable | Serialize and deserialize Java objects using Google’s Protocol buffers. |
Protobuf Jackson | Stable | Marshal POJOs to Protobuf and back using Jackson. |
RSS | Stable | Transform from ROME SyndFeed Java Objects to XML and vice-versa. |
SOAP | Stable | Marshal Java objects to SOAP messages and back. |
Syslog | Stable | Marshall SyslogMessages to RFC3164 and RFC5424 messages and back. |
Tar File | Stable | Archive files into tarballs or extract files from tarballs. |
Thrift | Stable | Serialize and deserialize messages using Apache Thrift binary data format. |
uniVocity CSV | Stable | Marshal and unmarshal Java objects from and to CSV (Comma Separated Values) using UniVocity Parsers. |
uniVocity Fixed Length | Stable | Marshal and unmarshal Java objects from and to fixed length records using UniVocity Parsers. |
uniVocity TSV | Stable | Marshal and unmarshal Java objects from and to TSV (Tab-Separated Values) records using UniVocity Parsers. |
XML Security | Stable | Encrypt and decrypt XML payloads using Apache Santuario. |
XStream | Stable | Marshal and unmarshal POJOs to/from XML using XStream library. |
YAML SnakeYAML | Stable | Marshal and unmarshal Java objects to and from YAML using SnakeYAML |
Zip Deflater | Stable | Compress and decompress streams using java.util.zip.Deflater and java.util.zip.Inflater. |
Zip File | Stable | Compression and decompress streams using java.util.zip.ZipStream. |
type convert数据类型转换
Camel路由中定义的消息在处理过程中,对消息类型处理可以通过类型转换方式来实现不通对象的转换处理,类似于常见的编程语言中的类型转换过程。
参考资料
- https://blog.csdn.net/GuoDa_/article/details/105947744?utm_medium=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase
- https://livebook.manning.com/book/camel-in-action/chapter-3/139
- https://blog.csdn.net/simba_cheng/category_7352732.html
- https://tomd.xyz/tag/apache-camel/
- https://camel.apache.org/manual/camelcontext.html