
Apache Camel实战
Apache Camel 是一个非常强大的基于规则的路由以及媒介引擎,该引擎提供了一个基于POJO的 企业应用模式(Enterprise Integration Patterns)的实现,你可以采用其异常强大且十分易用的API来配置其路由或者中介的规则
西夏一品堂
对新技术持开放且慎重的态度,开放在于新技术到来时有自己的尝试与思考,慎重在于对没有多大价值的所谓的新技术持有自己的判断。绝大部分所谓的新技术都没有多大价值。
展开
-
Apache Camel读取配置文件
方法一: 方法二: 引用属性和上面的方法一样camel版本:2.14.1原创 2015-09-17 16:50:20 · 3521 阅读 · 0 评论 -
Apache Camel TypeConverter的使用
TypeConverter是用来把一个对象转换成另一个对象,官方的文档地址为:http://camel.apache.org/type-converter.html测试环境 org.apache.camel camel-core 2.15.2 provided下面例子展示了TypeConverter的两种用法package org.demo.osgi;原创 2015-12-25 11:08:57 · 2572 阅读 · 0 评论 -
Apache Camel rest实现重定向
很简单在http返回的header里面加一个Location消息头,返回码改成301示例代码如下:package com.lala.rest.bean;import org.apache.camel.Exchange;import org.apache.camel.Processor;public class RedirectProcessor imple原创 2015-12-18 10:02:44 · 3563 阅读 · 0 评论 -
Apache Camel rest获取GET请求的参数
Apache Camel rest组件内部可以使用多个框架实现rest,比如restlet、jetty、servlet等等,我这里使用restlet首先加入依赖 org.apache.camel camel-restlet 2.15.2 provided这里先配置一个简单的rest服务<beans xmlns="http://www.springframew原创 2015-12-03 09:28:18 · 7201 阅读 · 1 评论 -
Apache Camel配置SSL的CXF
系统环境:java version "1.8.0_66"apache camel: 2.15.2一:创建证书,并导出公钥证书二:1: 加入maven依赖 org.apache.camel camel-cxf 2.15.2 org.apache.camel camel-spring 2.15.2 org.a原创 2015-11-18 17:25:35 · 2198 阅读 · 0 评论 -
Apache Camel配置SSL的rest
系统环境:java version "1.8.0_66"apache camel: 2.15.2关于rest组件的用法,请参照:http://blog.youkuaiyun.com/mn960mn/article/details/48372565那么,如何配置ssl呢,请继续往下看一:创建证书1:创建密钥对keytool -genkeypair -ali原创 2015-11-17 21:48:30 · 2749 阅读 · 0 评论 -
Apache Camel添加动态路由
方法一:定义RoutBuilder的方法public static void fun1(String[] args) throws Exception { ModelCamelContext context = new DefaultCamelContext(); context.start(); RouteBuilder route = new RouteBuilde原创 2015-10-08 09:52:46 · 6824 阅读 · 0 评论 -
使用Apache Camel处理web service请求的三种方法
一:首先写一个接口,用来发布web servicepackage com.pp.ws;import javax.jws.WebMethod;import javax.jws.WebService;/** * 计算器接口 */@WebServicepublic interface Calculator { @WebMethod public String getVer原创 2015-09-30 09:53:41 · 9404 阅读 · 0 评论 -
Apache Camel异常处理
直接看代码package com.lala.bean;import org.apache.camel.Exchange;import org.apache.camel.Processor;public class TestBean implements Processor { private String appId; public void process(Exchange原创 2015-09-14 22:07:12 · 4737 阅读 · 1 评论 -
Apache Came组件rest的使用
The rest component allows to define REST endpoints using the Rest DSL and plugin to other Camel components as the REST transport.代码如下:原创 2015-09-11 14:34:56 · 2085 阅读 · 0 评论 -
Apache Came组件http4的使用
http : For calling out to external HTTP servers using Apache HTTP Client 3.xhttp4 : For calling out to external HTTP servers using Apache HTTP Client 4.xhttp、http4其实是一样的,只是底层用的http client版本不一样现在以http4原创 2015-09-11 12:02:40 · 2969 阅读 · 0 评论 -
Apache Camel中的recipientList和routingSlip的区别?
二者都是根据消息来动态的路由到一个多个结点简单用法如下: endlist endlist ProducerTemplate pt = context.getBean("camelTemplate", ProducerTemplate.class); pt.send("direct:routingSlip", new Processor原创 2015-09-06 16:57:33 · 2154 阅读 · 0 评论 -
Apache Camel的multicast简单示例
这里以一个问题开始:和有什么区别?回答:加了multicast后,消息会复制多份,发送到后面所有的to节点,multicast可以指定线程池来并发,发送消息 没加的话,消息会依次流转到后面的节点 package com.pp.原创 2015-09-06 09:52:35 · 2820 阅读 · 1 评论 -
Apache Camel的sample的简单示例
sample(中文翻译为采样):单位时间内只能有指定个数的节点才能通过,剩余的丢弃 调用:ProducerTemplate pt = context.getBean("camelContextTemplate", ProducerTemplate.class);for(int i=1;i<=12;i++){原创 2015-09-05 20:40:48 · 2642 阅读 · 0 评论 -
Apache Camel的routingSlip简单示例
有些特殊的消息我们需要根据消息来动态的路由到一个多个结点。这是我们可以采用routing Slip的模式 routes package com.lala.bean;import org.apache.camel.Exchange;import org原创 2015-09-05 10:18:01 · 1808 阅读 · 0 评论 -
Apache Camel的aggregate简单示例
aggregate表示聚合,把相同类型的对象聚集起来,形成一个新的对象返回出去下面的例子演示了一个聚合求用户总得分的例子<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http:/原创 2015-09-04 23:59:14 · 3303 阅读 · 0 评论 -
Apache Camel的split使用示例
用法一: ${in.header.ids} ${in.body} com.lala.util.Split.javapackage com.lala.util;import java.util.Arrays;import java.ut原创 2015-09-04 19:23:31 · 3180 阅读 · 0 评论 -
Apache Camel的Header、Property、Body配置示例
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring" xsi:schemaL原创 2015-09-04 18:11:31 · 4662 阅读 · 0 评论 -
三种方式配置Camel的ProducerTemplate
这里以spring的配置文件为例,代码如下<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring" xsi:sch原创 2015-08-26 19:04:30 · 4957 阅读 · 0 评论