设为首页 收藏本站
查看: 1276|回复: 0

[经验分享] Apache ServiceMix学习【使用整合】1

[复制链接]

尚未签到

发表于 2017-1-5 07:39:25 | 显示全部楼层 |阅读模式
  1.     serviceMix 特点:
支持的协议有:
File;FTP;Http/s;jms;smtp;soap;tcp;xmpp
与其他引擎的支持:
Apache Camel;apache cxf;apache ode;drools;os workflow;pojos;quartz;scripting;saxon Xquery and xslt;ws-notification
支持的安全:
JAAS,WS-Security
与web 容器的集成
JBoss,Geronimo,jetty,tomcat,weblogic,websphere
 

2.     与Camel 集成
先查看是否存在camel相关features,没有则按照相应的bundles
接下来我们做一个例子:分别设置两个目录input和output,在input放入文件后则被传送到output中。而这个过程就是通过serviceMix调用camel router来完成
A. Blueprint xml file
下面是一个配置的router文件描述,你可以通过自己写文件,当然最好还是用可视化工具,后面我们再花时间聊聊这东东,这个时候就绕不开Enterprise Integration pattern 又是标准,老外厉害。
 我们这里直接先贴上文件:
<?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">
 
    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <route>
            <from uri="file:bgao/input" />
            <log message="happy day!!!" />
            <to uri="file:bgao/output" />
        </route>
    </camelContext>
</blueprint>
并命名为firstCamelRouter.xml
 
B. 配置到serviceMix
将文件放入到serviceMix的deploy中,这个时候后再serviceMix目录下发现bgao的目录并下面有个input文件夹,这时候如果在input文件夹放入一个文件,这bgao目录下会出现output目录并且将input目录的文件移到output上。通过log:display  可以查看到当前这个动作的日志。
 
通过karaf@root> osgi:list | grep xml
[  43] [Active     ] [GracePeriod ] [       ] [   60] activemq-broker.xml (0.0.0
)
[ 129] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundl
es :: xmlsec (1.4.5.1)
[ 138] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundl
es :: xmlbeans (2.4.0.4)
[ 142] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundl
es :: xmlresolver (1.2.0.3)
[ 163] [Active     ] [Created     ] [       ] [   60] firstCamelRouter.xml (0.0.
0)
得到当前ID为163;通过osgi:stop 163或者  osgi:start 163 来启动或者关闭当前bundle
 
3.     与ActiveMQ集成
先查看是否存在camel相关features, 没有则按照相应的bundles
我们做一个例子:
对两个文件进行文件移动,同时对MQ队列产生一个event 消息并捕获消息打出到日志。
第一个文件:firstMq.xml
<?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">
 
    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <route>
            <from uri="file:bgao/mq/input" />
            <to uri="file:bgao/mq/output" />         
                <setBody>
                <simple>
                File Move Event (${file:name},${date:now:hh:MM:ss.SSS})
                </simple>
                </setBody>
                <to uri="activemq://event" />
        </route>         
    </camelContext>
</blueprint>
这时候,文件已经移到output,现在是event message都在队列里面,但还没有人去处理他,现在通过secondeMq里处理她。
设置第二个文件 secondMq.xml 放入deloy文件夹中
<?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">
 
    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <route>
        <from uri="activemq://event" />
            <from uri="file:bgao/mq/input" />
            <to uri="log:events" />         
        </route>         
    </camelContext>
</blueprint>
启动当前这个bundle 然后打日志就发现有
2012-06-11 16:01:43,751 | INFO  | sConsumer[event] | events
      | ?                                   ? | 91 - org.apache.camel.camel-core
 - 2.8.4 | Exchange[ExchangePattern:InOnly, BodyType:String, Body:
                        File Move Event (address list20120130.xls,04:06:08.272)
                        ]
2012-06-11 16:01:43,751 | INFO  | sConsumer[event] | events
      | ?                                   ? | 91 - org.apache.camel.camel-core
 - 2.8.4 | Exchange[ExchangePattern:InOnly, BodyType:String, Body:
                        File Move Event (jms-1_1-fr-spec.pdf,04:06:08.469)
                        ]
2012-06-11 16:01:43,752 | INFO  | sConsumer[event] | events
      | ?                                   ? | 91 - org.apache.camel.camel-core
 - 2.8.4 | Exchange[ExchangePattern:InOnly, BodyType:String, Body:
                        File Move Event (新建文本文档 (3).txt,04:06:08.765)
 

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-323944-1-1.html 上篇帖子: Apache + PHP + SSL配置 + Tomcat CAS配置 下篇帖子: 增大apache 2的最大连接数
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表