Rube GoldbergSpring整合

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整合的你好”,
  • 将其拆分为单个单词(您好,来自spring,integeg),
  • 将每个单词发送到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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/372499.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

NSNotificationCenter

前几天面试富途证券&#xff0c;被问到添加通知的相关问题&#xff0c;当时有几个问题答错了&#xff0c;在此总结。 使用通知的要点 1.注册多少次&#xff0c;他的执行代码就会执行多少次 //1、注册多个通知 for (int i 0; i<3; i) {[[NSNotificationCenter defaultCenter]…

java ajax html复选框,HTMLjavaSkcriptCSSjQueryajax(九)(示例代码)

一、HTML1、单选按钮 Male Female2、复选框 I have a Car3、下拉列表 VoloFita如果设置某项选定直接 fem4、设置文本域 创建按钮 5、Runnob.com因为a 标签的target属性名是inframe_a的iframe框架&#xff0c;点击链接后页面会在iframe 中出现。6、脚本 JavaScript …

Spring和JSF集成:选择项目

使用JSF&#xff0c;要使用组合框&#xff0c;列表框和复选框&#xff0c;您需要了解javax.faces.model.SelectItem类。 SelectItem表示单个可选选项。 它既包含渲染所需的信息&#xff0c;又包含选择该项目时应绑定的值。 在大多数情况下&#xff0c; SelectItems是使用值和标…

apt-get update 问题 及gcc高亮

一 gcc高亮 gcc 高亮有好几种方法。 参考 http://www.cokco.cn/thread-39909-1-1.html 这个教程&#xff1a; &#xff08;1&#xff09; git clone https://github.com/chinaran/color-compile/ &#xff08;2&#xff09; cd color-compile make sudo make install&#xff0…

对于MVC中应用百度富文本编辑器问题的解决办法

&#xff11;.对于应用富文本编辑器&#xff50;&#xff4f;&#xff53;&#xff54;提交表单内容提示有危险的解决办法&#xff1a; [ValidateInput(false)] //文本编辑器的表单提交不用提示危险 [HttpPost] public ActionResult Create(FormCollection collection) 即在视图…

html5页面热力图几十万数据,基于百度地图的数据可视化,包括大量数据的标绘以及热力图的插入...

(function(global, factory) {typeof exports object && typeof module ! undefined ? module.exports factory() :typeof define function && define.amd ? define(factory) :(global.PointLine factory());}(this, (function() {use strict;/*** autho…

管理Jenkins作业配置

在JBoss工具和Developer Studio中&#xff0c;我们在Jenkins中管理许多构建作业。 实际上&#xff0c;对于3.2.x / 4.x和3.3.x / 5.x流&#xff0c;有195个以上的作业。 当我们开始建立明年的第一个里程碑时&#xff0c;我们将再产生40多个工作岗位。 这里是其中的一些&#xf…

Redis命令拾遗三(列表List类型)

本文版权归博客园和作者吴双本人共同所有。转载和爬虫请注明原文地址 Redis五种数据类型之列表类型Redis五种数据类型之列表类型。你可以存储一个有序的字符串列表一类数据。比如你想展示你所存储的所有文章中的前十条&#xff0c;当分页取下一页的时候&#xff0c;你也可以取接…

angular2安装笔记

主要摘自&#xff1a;http://www.runoob.com/angularjs2/angularjs2-typescript-setup.html http://blog.csdn.net/lgpwwa/article/details/51788035 开始尝试的时候npm install一直不能正常生成modules文件内的东东&#xff0c;后来试了多次才知道&#xff0c;大概是因为服务器…

计算机桌面上的声音图标没了怎么办,电脑声音图标不见了怎么办超详细教程

我们在用电脑或者平板看视频、听歌的时候&#xff0c;如果声音不合适&#xff0c;大了或小了就会调节音量&#xff0c;除了可以选择设备自带的外部音量大小调节按键外&#xff0c;还可以用自带的声音图标来调节&#xff0c;而屏幕上的声音图标是最方便的。如果屏幕上的声音图标…

XML解组基准:JAXB,STAx,Woodstox

介绍 上周末&#xff0c;我开始考虑如何以一种资源友好的方式处理大量XML数据。我要解决的主要问题是如何以块的形式处理大型XML文件&#xff0c;同时提供上游/下游系统&#xff0c;需要处理一些数据。 当然&#xff0c;我已经使用JAXB技术已有几年了。 使用JAXB的主要优点是可…

ArcGIS空间分析工具

1. 3D分析 1.1. 3D Features toolset 工具 工具 描述 3D Features toolset &#xff08;3D 要素工具集&#xff09; Add Z Information 添加 Z 信息 添加关于具有 Z 值的要素类中的要素的高程属性的信息。 Buffer 3D 3D 缓冲 围绕点或线创建三维缓冲区以生成球形或圆柱形的多面…

SHELL编程中如果路径名遇到括号

linux中&#xff0c;如果文件名中带括号&#xff0c;应先对括号处理&#xff0c;在“(”和“&#xff09;”前加上“\”。Bracket_Handle给出了处理方法&#xff1a;sub Bracket_Handle { my ($tmp_name) _; $tmp_name ~ s/\(/\\\(/g; # ( > \( $tmp_name ~ s/\)/…

计算机科学家和心理学家合作,生物智能与人工智能之间的合作

李飞飞带领的斯坦福“以人为本AI研究院”发表文章&#xff0c;探讨人工智能、神经科学、心理学和认知科学&#xff0c;以及数学、物理和社会科学等学科过去是怎样、以及未来将如何共同合作&#xff0c;追求对理解和创造智能系统的探索。最初的类人智能出现在几百万年前的非洲大…

JavaOne 2012 – 2400小时! 一些建议

您可能已经看到JavaOne 2012 Content Catalog在线。 计划委员会经过数周的艰苦工作&#xff0c;对每个提案进行了分类&#xff0c;审查&#xff0c;评分和讨论&#xff0c;我们终于为您设置了&#xff08;希望如此&#xff09;有趣的组合。 整整105天或2400个小时&#xff0c;我…

C语言

自定义函数 &#xff08;1&#xff09;在函数使用之前定义函数 &#xff08;2&#xff09;先声明这个函数&#xff0c;然后使用&#xff0c;使用的代码后面定义这个函数 include <stdio.h> void syahello(){ println("helloo"); }int main(){ sayhello(); // 调…

【Centos】yum 安装mariaDB

[dream361za ~]$ sudo yum search mariadb #查找需安装的包 mariadb-libs.x86_64 : The shared libraries required for MariaDB/MySQL clients #mariadb客户端 mariadb-server.x86_64 : The MariaDB server and related files #mariadb服务 [dream361za ~]$ sudo yum instal…

对口升学计算机组装与维护,对口升学信息技术(计算机)类2017年专业课考试大纲...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼山西省中等职业学校对口升学考试大纲信息技术类专业本考试大纲是以国家中等职业学校计算机专业教学指导方案为依据&#xff0c;以中等职业教育国家规划教材《物理(电工电子类)》(李广华、郝翠兰主编&#xff0c;电子工业出版社)、《…

网页性能优化(初窥)

面试的时候经常会被问到的有关于前端性能优化这一块的问题&#xff0c;扯扯个人的理解 第一条&#xff1a;减少 HTTP 次数的请求 80%的最终用户响应时间花在前端程序上&#xff0c;而其大部分时间则花在各种页面元素&#xff0c; 如图像、 样式表、 脚本和 Flash 等&#xff0c…

STM32F10x_硬件I2C主从通信(轮询发送,中断接收)

Ⅰ、写在前面 关注我分享文章的朋友应该知道我在前面讲述过&#xff08;软件、硬件&#xff09;I2C主机控制从机EEPROM的例子。在I2C通信主机控制程序是比较常见的一种&#xff0c;可以说在实际项目中&#xff0c;很多应用都会使用到I2C通信。但在实际项目中作为I2C从机的应用相…