rube3xxx

Spring Integration为集成系统所涉及的一些复杂性提供了非常好的抽象-Spring Integration从Integration的角度完美地满足了Facade的定义-简化了对复杂基础系统的访问。

为了说明这一点,请考虑一个简单的系统,该系统仅接收一条消息,然后将其发送回大写,称其为Echo网关:

public interface EchoGateway { String echo(String message);
}

并为此进行测试:

@Testpublic void testEcho() {String response = echoGateway.echo('Hello');assertThat(response, is('HELLO'));}

到目前为止听起来很简单,使用spring集成的实现将通过转换为大写并返回增强后的消息来接受“消息”并对其进行“转换”。

<?xml version='1.0' encoding='UTF-8'?>
<beans:beans xmlns='http://www.springframework.org/schema/integration'xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'xmlns:beans='http://www.springframework.org/schema/beans'xsi:schemaLocation='http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd'><channel id='requestChannel'/><gateway id='echoGateway' service-interface='rube.simple.EchoGateway' default-request-channel='requestChannel' /><transformer input-channel='requestChannel' expression='payload.toUpperCase()' />  </beans:beans>

作品精美!

Spring Integration的优点在于,即使Integration场景变得复杂,它呈现给应用程序的外观仍然保持简单,

考虑一个Rube Goldberg集成方案:

首先是描述旋流的图表:

那么它到底是做什么的:

  • 它接收到这样的消息-“来自Spring整合的你好”,
  • 将其拆分为单个词(您好,来自,春天,完整),
  • 将每个单词发送到ActiveMQ队列,
  • 从队列中,单词片段被浓缩器拾取以大写每个单词,
  • 将响应放回响应队列,
  • 根据单词的原始顺序对其进行重新排序,
  • 聚合成一个句子(“ HELLO FROM SPRING INTEG”),
  • 返回到应用程序。

这是这种流程的Spring Integration配置的样子:

<?xml version='1.0' encoding='UTF-8'?>
<beans:beans xmlns='http://www.springframework.org/schema/integration'xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'xmlns:int-jms='http://www.springframework.org/schema/integration/jms'xmlns:beans='http://www.springframework.org/schema/beans'xsi:schemaLocation='http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsdhttp://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsdhttp://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms-2.1.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd'><beans:import resource='broker.xml'/><channel id='requestChannel'><queue/>  </channel><channel id='responseChannel'><queue/></channel><gateway id='echoGateway' service-interface='rube.complicated.EchoGateway' default-request-channel='requestChannel' default-reply-channel='responseChannel' default-reply-timeout='5000' /><channel id='toJmsOutbound'/><splitter input-channel='requestChannel' output-channel='toJmsOutbound' expression='payload.split('\s')'></splitter><channel id='sequenceChannel'></channel><int-jms:outbound-gateway request-channel='toJmsOutbound' reply-channel='sequenceChannel' request-destination='amq.outbound' extract-request-payload='true' /><channel id='enhanceMessageChannel'/><channel id='toReplyQueueChannel'/><int-jms:inbound-gateway request-channel='enhanceMessageChannel' request-destination='amq.outbound' reply-channel='toReplyQueueChannel'/><transformer input-channel='enhanceMessageChannel' expression='(payload + '').toUpperCase()' output-channel='toReplyQueueChannel'/><resequencer input-channel='sequenceChannel' output-channel='aggregateChannel' release-partial-sequences='false'></resequencer><aggregator input-channel='aggregateChannel' output-channel='responseChannel'  expression='T(com.google.common.base.Joiner).on(' ').join(![payload].toArray())'/><poller id='poller' fixed-delay='500' default='true'/></beans:beans>

这个流程有太多的复杂性(因此,Rube Goldberg也是如此),但是Spring Integration提供给应用程序的外观仍然非常简单。

@Testpublic void testEcho() throws Exception{String amessage = 'Hello from Spring Integration';String response = echoGateway.echo(amessage);assertThat(response, is('HELLO FROM SPRING INTEGRATION'));}

我认为这是Spring Integration的本质

我在https://github.com/bijukunjummen/rg-si.git上有一个包含此代码的github存储库。

参考: all和其他博客中的Rube Goldberg Spring Integration,来自我们的JCG合作伙伴 Biju Kunjummen。

翻译自: https://www.javacodegeeks.com/2012/06/rube-goldberg-spring-integration_22.html

rube3xxx

rube3xxx_Rube GoldbergSpring整合相关推荐

  1. Rube GoldbergSpring整合

    Spring Integration为集成系统所涉及的某些复杂性提供了非常好的抽象-Spring Integration从Integration的角度来看非常适合Facade的定义-简化了对复杂底层系 ...

  2. Spring Boot整合Spring Data JPA操作数据

    一. Sping Data JPA 简介 Spring Data JPA 是 Spring 基于 ORM 框架.JPA 规范的基础上封装的一套 JPA 应用框架,底层使用了 Hibernate 的 J ...

  3. ssh(Struts+spring+Hibernate)三大框架整合-简述

    ssh(Struts+spring+Hibernate)三大框架配合使用来开发项目,是目前javaee最流行的开发方式,必须掌握: 注意: 为了稳健起见,每加入一个框架,我们就需要测试一下,必须通过才 ...

  4. struts2 与 sping 整合 控制器中 service注入的问题

    以个人见解认为struts1 与spring整合的时候按照习惯,我们会把 action 控制器直接配置到sping中去: eg : 这里以使用元注解方式实现Service注入进行讲解: 控制器关键代码 ...

  5. Strutsw2与Spring整合流程-简述

    1.      新建WEB工程: 2.      导入struts2开发包,和资源配置文件 ① globalMessages.properties ② struts.properties 3.     ...

  6. 【牛腩新闻发布系统】整合前台04

    前言: 后台,前台完成后,整合界面会变得非常简单 整理前台的问题总结: 1. 数据绑定 2. html语言问题 3. 莫名错误,重试解决 4. 整合收缩页 5. 整合新闻内容页 6. 整个前台页面出错 ...

  7. SSM框架整合(Spring+SpringMVC+MyBatis)

    输出结果 1.Maven Web项目创建 之前有写过Eclipse+Maven创建web项目的帖子,如果需要,请参考这里写链接内容 创建好项目之后因为入下图: 2.SSM整合 2.1 引入需要的JAR ...

  8. SpringBoot整合Shiro安全框架完整实现

    目录 一.环境搭建 1. 导入shiro-spring依赖 2. 编写首页及其controller 3. 编写shiro配置类 二.Shiro实现登录拦截 1. 编写页面及其controller 2. ...

  9. SpringBoot整合MyBatis详细教程~

    目录 1. 导入依赖 2. 连接数据库 3. 编写数据库配置信息 4. 编写pojo实体类 5. 编写mapper接口 6. 编写mapper.xml 7. 编写controller 8. 测试 1. ...

最新文章

  1. stella forum v1.2 用例分析
  2. Windows 8测试版安装图组
  3. 请你说明一下TreeMap的底层实现?
  4. python列透视_python – 在pandas数据帧中透视列和列值
  5. PowerDesigner生成mysql字段comment 注释
  6. 求关于运动的英语(收集)
  7. Python自动化中的元素定位xpath(二)
  8. 12月1日struts、spring、hibernate等框架的整合培训日记
  9. 【元胞自动机】基于matlab元胞自动机传染病传播模拟【含Matlab源码 1680期】
  10. cim系统(cim系统包含哪些部分)
  11. mysql报错You do not have the SUPER privilege and binary logging is enabled
  12. 聚焦质控 | 如何进行单病种过程质量管理
  13. matlab抢占时隙算法,ALOHA anti-collision、二进制数搜索算法以及帧时隙算法
  14. Java下载Excel文件
  15. 逃离烤鸭味的雾霾北京,我们还能去哪里?
  16. Stm32 - Printf重定向(不)使用微库(Keil MDK)
  17. 饿了么被上海市市场监督局予以警告处分
  18. LeetCode算法题解 414-第三大的数
  19. PHP--有道(百度)文字或语句转MP3音频文件
  20. 使用python代替matlab仿真线性控制系统(倒立摆)

热门文章

  1. 公众号新上线微信小游戏(疯狂猜图)
  2. 新闻发布项目——业务逻辑层(UserService)
  3. String与StringBuffer、StringBuilder之间的转换
  4. 表单中去掉重置和提交按钮和搜索框
  5. netapp做内网穿透有问题
  6. Servlet请求和响应总结
  7. 搭建一个简单的Spring boot+maven项目
  8. java第三阶段源代码_有效Java第三版的源代码已更新为使用较新的功能
  9. java观察者设计模式_Java中的观察者设计模式
  10. 文档在线签名_为什么需要为文档和合同切换到在线签名