这篇的基础是上一篇Camel相关的内容,在http://servicemix.apache.org/docs/4.3.0-SNAPSHOT/quickstart/quickstart.pdf这书中,这部分的内容叫做AddingActiveMQ to the'Mix,其实就是在上一篇的基础上,把记录日志的功能拆成两部,在完成文件的转移后,朝activemq的队列中发送一个事件,然后从另一个bundles里接收该事件并写到日志中。
原来的blueprint.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">
<camelContextxmlns="http://camel.apache.org/schema/blueprint">
<route>
<fromuri="file:activemq/input"/>
<touri="file:activemq/output"/>
<setBody>
<simple>
FileMovedEvent(file: ${file:name}, timestamp:${date:now:hh:MM:ss.SSS})
</simple>
</setBody>
<to uri="activemq://events" />
</route>
</camelContext>
</blueprint>
-----------------------------------------------------------------------------
然后再增加一个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">
<camelContextxmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="activemq://events"/>
<to uri="log:events"/>
</route>
</camelContext>
</blueprint>
-----------------------------------------------------------------------------
心得:
这部分内容比较简单,基本上有点语言基础就能看懂这个过程吧。两个xml的内容是自动部署的,应该很好理解这个过程。
原来的blueprint.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">
<camelContextxmlns="http://camel.apache.org/schema/blueprint">
<route>
<fromuri="file:activemq/input"/>
<touri="file:activemq/output"/>
<setBody>
<simple>
FileMovedEvent(file: ${file:name}, timestamp:${date:now:hh:MM:ss.SSS})
</simple>
</setBody>
<to uri="activemq://events" />
</route>
</camelContext>
</blueprint>
-----------------------------------------------------------------------------
然后再增加一个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">
<camelContextxmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="activemq://events"/>
<to uri="log:events"/>
</route>
</camelContext>
</blueprint>
-----------------------------------------------------------------------------
心得:
这部分内容比较简单,基本上有点语言基础就能看懂这个过程吧。两个xml的内容是自动部署的,应该很好理解这个过程。