这段时间做大客户项目,大量的业务系统,错综复杂的调用关系,每天就是在不停的与外系统沟通,不得已对企业集成做了点小了解,重点体验了下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是一个功能强大的EIP(Enterprise Integration Patterns),即企业集成模式。对,spring-integration是一个集大成者。就我自己的理解,集成了众多功能的它,是一种便捷的事件驱动消息框架用来在系统...
是Spring框架创建的又一个API,面向企业应用集成(EAI)。Spring Integration非常轻量、易于测试;几乎没有入门门槛,概念上比任何“自己编写”的解决方法都要简单。长远来看,它更为灵活、更具有适应性。一旦使用,...
Java/Spring 项目的事件总线库,基于 Spring 集成框架。 事件驱动架构促进了事件发布者和事件订阅者之间松散耦合的交互。 事件本质上是具有附加语义的消息,这就是为什么许多事件基础设施都建立在某种消息传递框架...
Spring Integration 提供了 Spring 框架的扩展以支持著名的企业集成模式。 它在基于 Spring 的应用程序中启用轻量级消息传递并支持与外部系统的集成。 Spring Integration 最重要的目标之一是为构建可维护和可测试的...
介绍Spring Cloud Stream与RabbitMQ集成的代码示例。Spring Cloud Stream是一个建立在Spring Boot和Spring Integration之上的框架,有助于创建事件驱动或消息驱动的微服务。
使用 Apache Camel 和 Spring 集成的企业集成模式。 用于使用框架演示 EIP 的域是自行车商店。 自行车商店导入 CSV 交货单和订单。 ##Import of delivery notes 每条交货单记录都被转换成一个StockItem 并发送到eip....
不知道为啥Spring这家伙为啥在java下有那么高的地位,感觉走到哪里都要用到它,不过无可否认java下Spring本身对于常见的框架都提供了很好的集成。很早以前.net和java程序员互相说自己好,对方不好的时候,看过过一句...
使用Spring集成和Redis队列显示微服务之间的通信的示例 该项目由生产者,消费者和消息传递框架组成。 下载并导入所有三个项目。 在Messaging-library项目上执行Maven安装(*重要) 在计算机上安装redis(有关下载...
第6章 将Spring与其他Web框架集成 209 6.1 在一般Web应用中访问Spring 209 6.1.1 问题 209 6.1.2 解决方案 210 6.1.3 工作原理 210 6.2 在你的Servlet和过滤器中使用Spring 214 6.2.1 问题 214 6.2.2...
整合 Adobe Flex 和 Spring 的关键就在于提供一种方法使得 Adobe Flex 客户端程序可以很容易访问到 Spring...利用开源框架 BlazeDS 和 Spring BlazeDS Integration 来集成 Adobe Flex 和 Spring 可以帮助你做到这一点。
13.1.2. Spring Web MVC框架的特点 13.2. DispatcherServlet 13.3. 控制器 13.3.1. AbstractController 和 WebContentGenerator 13.3.2. 其它的简单控制器 13.3.3. MultiActionController 13.3.4. 命令控制器 ...
第6章 将Spring与其他Web框架集成 209 6.1 在一般Web应用中访问Spring 209 6.1.1 问题 209 6.1.2 解决方案 210 6.1.3 工作原理 210 6.2 在你的Servlet和过滤器中使用Spring 214 6.2.1 问题 214 6.2.2...
13.1.2. Spring Web MVC框架的特点 13.2. DispatcherServlet 13.3. 控制器 13.3.1. AbstractController 和 WebContentGenerator 13.3.2. 其它的简单控制器 13.3.3. MultiActionController 13.3.4. 命令控制器 13.4. ...
SpringSip 是 Spring 框架的附加组件,它将基于 Java 的 NIST SIP 堆栈作为单例 bean 集成到 Spring 中。 NIST SIP 堆栈的这种集成提供的附加组件更易于部署和测试。
9.4 系统集成Spring Integration 395 9.4.1 Spring Integration 快速入门 395 9.4.2 Message 395 9.4.3 Channel 395 9.4.4 Message EndPoint 398 9.4.5 Spring Integration Java DSL 400 9.4.6 实战 400 第10 章 ...
13.1.2. Spring Web MVC框架的特点 13.2. DispatcherServlet 13.3. 控制器 13.3.1. AbstractController 和 WebContentGenerator 13.3.2. 其它的简单控制器 13.3.3. MultiActionController 13.3.4. 命令控制器 ...
13.1.2. Spring Web MVC框架的特点 13.2. DispatcherServlet 13.3. 控制器 13.3.1. AbstractController 和 WebContentGenerator 13.3.2. 其它的简单控制器 13.3.3. MultiActionController 13.3.4. 命令控制器 ...
9.4 系统集成Spring Integration 395 9.4.1 Spring Integration 快速入门 395 9.4.2 Message 395 9.4.3 Channel 395 9.4.4 Message EndPoint 398 9.4.5 Spring Integration Java DSL 400 9.4.6 实战 400 第10 章 ...
13.1.2. Spring Web MVC框架的特点 13.2. DispatcherServlet 13.3. 控制器 13.3.1. AbstractController 和 WebContentGenerator 13.3.2. 其它的简单控制器 13.3.3. MultiActionController 13.3.4. 命令控制器 ...
为了将其扩展到数据集成工作负载,Spring Integration 和 Spring Boot 被整合到一个新项目中。 Spring Cloud Stream 诞生了。 使用 Spring Cloud Stream,开发人员可以: 独立构建、测试和部署以数据为中心的应用...