学习ServiceMix笔记(五) 学习ServiceMix的blueprint配置
2014-04-18 00:00
302 查看
摘要: 对比两个blueprint配置文件看blueprint的基本使用方法
先来看两个blueprint配置文件,一个是上次实现启动停止服务的transfile.xml,一个是系统的examples\camel\camel-blueprint下的配置文件。内容如下:
transfile.xml
examples\camel\camel-blueprint
前一个文件分为 camelContext,bean两个节点,后一个分为 cm:property-placeholder,camelContext,bean三个节点,cm:property-placeholder是用来预定义一些camel的属性后面进行调用,我们只研究camelContext,bean两个节点。
对于camelContext,这是整个服务的关键所在,route指名了当前服务处理业务流程的出入口:我们先来看transfile.xml配置文件。
数据入口
对于transfile.xml文件来说,from 指名数据来源,操作对象file,对应文件操作功能(有关file的一个操作和属性设置具体请看http://camel.apache.org/file2.html)。
监测activemq/input目录下的文件变化,如果文件存在,那么读取文件,通过后而的数据处理过程进程处理。
2. 数据处理
在此配置文件中无数据处理过程,只是简单的文件读取,直接转发给数据出口的文件写入请求。
3. 数据出口
把读取到的文件,写入的指定的目录下。
这里对应另外一个数据出口,把接收文件的一些信息发送给activemq,setBody是一个简单的数据处理过程,也可以是自定义的数据处理过程。
接下来我们再看一下examples\camel\camel-blueprint中的xml文件里的内容:
数据入口
对于camel-blueprint的配置文件来说,from 指名数据来源,操作对象timer,定义了一个timer对象myTimer,定时执行指定的数据处理过程,timer操作是调用camel的Quartz服务,进行一些与时间有关的操作,具体属性请看http://camel.apache.org/timer.html里面的介绍。。
2. 数据处理
数据处理过程是一个JAVA类,调用类里的transform方法进行数据处理。
3. 数据出口
输出日志信息。
除了上面的file,timer,activem,log四个外,还有其它的操作吗?协议文件传送FTP,FTPS,WEB服务HTTP,websocket,邮件POP3,SMTP,竟然可以直接和MyBatis ,JDBC连接进行操作,这些我们以后再一点一点学习吧。有关其它可以调用的输入输出组件请查看介绍http://camel.apache.org/components.html。
先来看两个blueprint配置文件,一个是上次实现启动停止服务的transfile.xml,一个是系统的examples\camel\camel-blueprint下的配置文件。内容如下:
transfile.xml
<?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> <camelContext xmlns="http://camel.apache.org/schema/blueprint"> <route> <from uri="file:activemq/input"/> <to uri="file:activemq/output"/> <setBody> <simple> FileMovedEvent(file: ${file:name}, timestamp: ${date:now:hh:MM:ss.SSS}) </simple> </setBody> <to uri="activemq://events" /> </route> </camelContext> <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"> <property name="brokerURL" value="tcp://localhost:61616"/> <property name="userName" value="smx"/> <property name="password" value="smx"/> </bean> </blueprint>
examples\camel\camel-blueprint
<?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> <cm:property-placeholder persistent-id="org.apache.servicemix.examples"> <cm:default-properties> <cm:property name="prefix" value="Blueprint-Example"/> </cm:default-properties> </cm:property-placeholder> <camelContext xmlns="http://camel.apache.org/schema/blueprint"> <route> <from uri="timer://myTimer?fixedRate=true&period=2000" /> <bean ref="myTransform" method="transform"/> <to uri="log:ExampleRouterBlueprint" /> </route> </camelContext> <bean id="myTransform" class="org.apache.servicemix.examples.camel.MyTransform"> <property name="prefix" value="${prefix}" /> </bean> </blueprint>
前一个文件分为 camelContext,bean两个节点,后一个分为 cm:property-placeholder,camelContext,bean三个节点,cm:property-placeholder是用来预定义一些camel的属性后面进行调用,我们只研究camelContext,bean两个节点。
对于camelContext,这是整个服务的关键所在,route指名了当前服务处理业务流程的出入口:我们先来看transfile.xml配置文件。
数据入口
对于transfile.xml文件来说,from 指名数据来源,操作对象file,对应文件操作功能(有关file的一个操作和属性设置具体请看http://camel.apache.org/file2.html)。
<from uri="file:activemq/input"/>
监测activemq/input目录下的文件变化,如果文件存在,那么读取文件,通过后而的数据处理过程进程处理。
2. 数据处理
在此配置文件中无数据处理过程,只是简单的文件读取,直接转发给数据出口的文件写入请求。
3. 数据出口
<to uri="file:activemq/output"/>
把读取到的文件,写入的指定的目录下。
<setBody> <simple> FileMovedEvent(file: ${file:name}, timestamp: ${date:now:hh:MM:ss.SSS}) </simple> </setBody> <to uri="activemq://events" />
这里对应另外一个数据出口,把接收文件的一些信息发送给activemq,setBody是一个简单的数据处理过程,也可以是自定义的数据处理过程。
接下来我们再看一下examples\camel\camel-blueprint中的xml文件里的内容:
数据入口
对于camel-blueprint的配置文件来说,from 指名数据来源,操作对象timer,定义了一个timer对象myTimer,定时执行指定的数据处理过程,timer操作是调用camel的Quartz服务,进行一些与时间有关的操作,具体属性请看http://camel.apache.org/timer.html里面的介绍。。
<from uri="timer://myTimer?fixedRate=true&period=2000"/>
2. 数据处理
<bean ref="myTransform" method="transform"/>
数据处理过程是一个JAVA类,调用类里的transform方法进行数据处理。
3. 数据出口
<to uri="log:ExampleRouterBlueprint" />
输出日志信息。
除了上面的file,timer,activem,log四个外,还有其它的操作吗?协议文件传送FTP,FTPS,WEB服务HTTP,websocket,邮件POP3,SMTP,竟然可以直接和MyBatis ,JDBC连接进行操作,这些我们以后再一点一点学习吧。有关其它可以调用的输入输出组件请查看介绍http://camel.apache.org/components.html。
相关文章推荐
- cisco sdm登录 SSH配置学习笔记
- Log4cplus配置文件的使用(学习笔记)
- ZooKeeper3.4.6学习笔记(一)集群配置
- Hadoop学习笔记—22.Hadoop2.x环境搭建与配置
- entlib 5.0学习笔记 caching application block 3 详细配置及api使用
- nginx 学习笔记(9) 配置HTTPS服务器--转载
- 树莓派学习笔记——USB wifi配置指南
- 【caffe 学习笔记之1】 WIN10+VS2013+CUDA7.5下CPU/GPU caffe配置
- tomcat配置学习笔记
- Spring学习笔记之六(数据源的配置)
- [学习笔记]将LinqToSql的连接字符串写在配置文件中
- paper 58 :机器视觉学习笔记(1)——OpenCV配置
- php学习笔记:thinkphp 配置在nginx的坑
- h5学习笔记:vuethink 配置
- Mybatis源码学习笔记(六)配置简介之objectFactory、plugins、mappers
- 【深度学习】笔记14 windows下caffe的python接口的配置(数据的可视化环境)
- Hadoop学习笔记—1.基本介绍与环境配置
- MongoDB 学习笔记(一)-MongoDB配置
- Maven学习笔记002——Maven的安装和配置(2017)
- Java学习笔记之JDK配置的作用和方法(含set设置临时环境变量)