这段时间做大客户项目,大量的业务系统,错综复杂的调用关系,每天就是在不停的与外系统沟通,不得已对企业集成做了点小了解,重点体验了下spring integreation。
忽略spring integration中的各种费解概念,就想弄点我想要的简单的应用集成模式,简化服务接入,服务编排工作,弄个类似tibco bw的process设计类似的小东西。
- 我所理解的概念
- 服务适配器 dapaper:描述各种类型的外系统接入,webService接入,rmi接入,wtc接入,ftp,jms等等。
- 服务 service :基本的服务调用。
- 服务流 flow:一组由service,filter,splitter,route,aggregator,transformer等连接起来的服务集合。
- 服务流程 :节点状态控制,节点流转控制,节点可以是服务,可以是服务流,以及其他类型。
- 我想要的功能
- 适配器定义
- 服务定义
- 服务流设计器
- 流程设计器
- 流程服务监控,服务统计,流量统计等
- 基于spring integration的尝试
1.可配置的json调用,通过http adapter可以发布我们的服务,服务流,流程等为http ajax调用,可以解决界面调用的问题,。
2.统一输入和输出
规范服务的输入和输出, 所有类型的服务输入输出都可被包装成统一模式。
3输入和输出的映射实现
在transformer中配置输出到输入的映射,使得服务A的结果可以再图形界面中映射到服务B。
4服务异常处理机制
5服务流事务处理机制
扫描二维码关注公众号,回复:
608014 查看本文章
- spring integration示例
示例描述
调用其他系统发布的rmi服务,rmi调用成功后继续调用webservice服务,其中rmi的结果映射到webservice服务的输入参数中,最终打印webservice中的返回结果.
spring配置文件
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.2.xsd http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file-2.2.xsd http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http-2.2.xsd http://www.springframework.org/schema/integration/rmi http://www.springframework.org/schema/integration/rmi/spring-integration-rmi-2.2.xsd http://www.springframework.org/schema/integration/ws http://www.springframework.org/schema/integration/ws/spring-integration-ws-2.2.xsd http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream-2.2.xsd" xmlns:int="http://www.springframework.org/schema/integration" xmlns:int-file="http://www.springframework.org/schema/integration/file" xmlns:int-http="http://www.springframework.org/schema/integration/http" xmlns:int-mail="http://www.springframework.org/schema/integration/mail" xmlns:int-rmi="http://www.springframework.org/schema/integration/rmi" xmlns:int-ws="http://www.springframework.org/schema/integration/ws" xmlns:int-stream="http://www.springframework.org/schema/integration/stream"> <!-- websercice调用处理类, 从输入中获取的参数转换成requestXml 从输出中获取responseXml装换成ResContext --> <bean name="wsInvoker" class="org.springframework.integration.samples.WebServiceInvoker" /> <!-- ResContext到json的装换实现 --> <bean name="jsonTransformer" class="com.gsoft.framework.esb.json.JsonTransformer"/> <!-- rmi请求入口channel --> <int:channel id="rmiRequestChannel"/> <!-- rmi 服务调用适配器 --> <int-rmi:outbound-gateway id="rmiGateway" request-channel="rmiRequestChannel" remote-channel="rmiExchange" host="127.0.0.1" reply-channel="rmiReply" /> <!-- rmi服务调用 --> <int:service-activator input-channel="rmiExchange" ref="rmiServiceFactory" method="exchange"/> <!-- rmi服务接口 --> <int:gateway id="rmiServiceFactory" service-interface="com.gsoft.framework.esb.rmi.RmiServiceFactory"/> <!-- 把rmi服务调用后的输出结果映射到webservice服务调用的输入中 --> <int:transformer input-channel="rmiReply" output-channel="helloWorldWsChannel" ref="rmi2hellWorldWsTransformer"></int:transformer> <!-- 配置输入输出的transformer,定义映射规则 --> <bean name="rmi2hellWorldWsTransformer" class="com.gsoft.framework.esb.data.ReqMapResTransformer"> <property name="mapping"> <map> <entry key="userName" value="#record.userName"></entry> </map> </property> </bean> <!-- websercice服务调用入口 --> <int:channel id="helloWorldWsChannel"/> <!-- 输入参数处理,从输入参数转换为requestXml --> <int:service-activator id="helloWordReqProcess" input-channel="helloWorldWsChannel" ref="wsInvoker" method="request" output-channel="helloWorldReqChannel" /> <!-- webservice 服务调用适配器 --> <int-ws:outbound-gateway request-channel="helloWorldReqChannel" id="helloWorldGateway" uri="http://localhost:8086/platform/services/HelloWorld" reply-channel="wsResChannel"/> <!-- 输出参数处理,从响应的responseXml装换成ResContext对象 --> <int:service-activator id="wsResRrocess" input-channel="wsResChannel" output-channel="wsReply" ref="wsInvoker" method="reply"/> <!-- ResContext到json格式的转换 --> <int:transformer input-channel="wsReply" ref="jsonTransformer" output-channel="log"/> <!-- 打印输出到控制台 --> <int-stream:stdout-channel-adapter id="log"/> </beans>
spring integration 图
测试代码
- 初步总结
- spring integration框架的应用集成可以简化我们很多的接口开发工作,通过自主开发设计器,能够把我们大部分的系统间服务调用装换成图形化的配置。
- 服务的切换是可行的。
- 服务调用的统计和监控工作的实现很容易切入。
- 性能上的优化是可自主掌控的。
- 服务的分解粒度已经可以很细。
- 服务,流程测试很方便;自主实现调试也是可行的。
- 部署和运维的集成也可行。