这段时间做大客户项目,大量的业务系统,错综复杂的调用关系,每天就是在不停的与外系统沟通,不得已对企业集成做了点小了解,重点体验了下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服务流事务处理机制
- 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框架的应用集成可以简化我们很多的接口开发工作,通过自主开发设计器,能够把我们大部分的系统间服务调用装换成图形化的配置。
- 服务的切换是可行的。
- 服务调用的统计和监控工作的实现很容易切入。
- 性能上的优化是可自主掌控的。
- 服务的分解粒度已经可以很细。
- 服务,流程测试很方便;自主实现调试也是可行的。
- 部署和运维的集成也可行。
相关推荐
Spring Integration 是一个基于 Java 的集成框架,旨在帮助开发者将不同的应用程序和系统集成在一起。它提供了一种基于消息的集成方式,允许开发者使用消息来交换数据。Spring Integration 提供了多种集成方式,包括...
- **Spring Integration 概览:** Spring Integration 是一个基于 Spring 框架的企业集成解决方案,它提供了一种声明式的、面向消息的方式来构建集成应用程序。 - **组件介绍:** Spring Integration 包括消息通道...
除了介绍Spring Integration的功能,文章还将其与其他集成框架进行了比较,指出Spring Integration相较于其他集成技术的优势。具体而言,Spring Integration紧密地与Spring框架集成,利用Spring的依赖注入和面向切面...
《Pro Spring Integration》是一本专注于Spring ...通过使用Spring Integration这样的企业集成框架,开发者能够不必对现有的应用程序进行大规模重构,从而简化和自动化业务流程,提高系统的整体效率和响应速度。
Spring Integration是Spring框架家族的一部分,它提供了一种声明式的方式来构建企业级应用的集成解决方案,使得系统间的数据流动变得更加简单和高效。这本书的随书源码提供了丰富的示例,帮助读者在实践中掌握该框架...
这本书深入探讨了Spring Integration这一强大的企业级应用集成框架,帮助开发者构建高效、灵活的系统连接。 Spring Integration是Spring生态体系中的一个重要组成部分,它简化了企业级应用之间的数据交换,通过提供...
Spring Integration 是 Spring 框架的重要组成部分,它为 Java 应用提供了一种轻量级、声明式的集成解决方案,使得在不同系统、服务间的数据交换变得简单易行。Spring Integration 提供了丰富的组件和适配器,能够...
**Spring Integration** 是Spring框架的一个扩展项目,它提供了构建企业集成应用程序所需的各种功能和支持。通过利用现有的Spring编程模型和依赖注入特性,Spring Integration使得开发人员能够轻松地实现消息传递、...
《Spring Integration in Action》这本书是关于Spring Integration框架的深度指南,该框架是Spring生态系统的组成部分,专注于企业应用集成。Spring Integration提供了一种简单且高效的方式来连接不同系统、服务和...
Spring Integration 是一个基于 Spring 框架的轻量级企业级集成库,它提供了一种声明式的方法来处理系统间的消息传递和数据流。这个"spring integration master"压缩包文件很可能是包含了一系列示例,帮助开发者更好...
Spring Integration 是 Spring 框架的一个扩展,旨在简化企业级应用中的集成问题。它提供了一种声明式的方式,用于处理系统间的异步通信、消息传递和数据转换。Spring Integration 提供了多种适配器,使得与外部系统...
本书《Pro Spring Integration》旨在为读者深入浅出地介绍如何利用Spring Integration来构建企业级集成应用。 **Spring Integration** 的设计目标是提供一种简单而灵活的方式来连接企业应用的各种组件和服务。它...
Java Spring Integration 是一个强大的框架,它扩展了Spring编程模型,以实现企业级应用程序之间的无缝集成。这个框架的主要目标是简化微服务、系统和服务之间的通信,遵循Enterprise Integration Patterns (EIP)这...
Spring Integration是由Spring框架团队开发的一个强大而灵活的企业级应用集成框架。它基于Spring的核心功能,提供了丰富的抽象层来简化不同系统之间的通信与数据交换。Spring Integration的目标是解决企业级应用中的...
这本书主要面向已经对Spring框架有一定了解的开发者,旨在通过实例和深入的讨论,展示如何使用Spring Integration来解决企业集成问题。Spring Integration是Spring框架的一部分,提供了一种轻量级的消息集成机制,它...
Spring Integration 是 Spring 框架的一个扩展,旨在提供轻量级、企业级的集成解决方案,它简化了应用程序之间的数据传输,支持多种协议和消息传递模式。在本文中,我们将深入探讨 Spring Integration 2.0.3 版本的...