英文原文:https://spring.io/projects/spring-integration

目录

概述

介绍

特性

例子

Spring Boot配置

快速开始

学习

文档

指南

示例


概述

扩展Spring编程模型以支持众所周知的企业集成模式。 Spring Integration在基于Spring的应用程序中实现轻量级消息传递,并支持通过声明适配器与外部系统集成。与Spring对远程处理,消息传递和调度的支持相比,这些适配器提供了更高级别的抽象。 Spring Integration的主要目标是提供一个简单的模型来构建企业集成解决方案,同时保持关注点的分离,这对于生成可维护,可测试的代码至关重要。

介绍

使用Spring Framework鼓励开发人员使用接口进行编码,并使用依赖注入(DI)为普通旧Java对象(PO​​JO)提供执行其任务所需的依赖项。 Spring Integration将这一概念更进一步,其中POJO使用消息传递范例连接在一起,并且各个组件可能不了解应用程序中的其他组件。这种应用程序是通过组装细粒度可重用组件来构建的,以形成更高级别的功能。通过精心设计,这些流程可以模块化,并在更高的层次上重复使用。

除了将细粒度组件连接在一起外,Spring Integration还提供多种通道适配器和网关,以便与外部系统进行通信。通道适配器用于单向集成(发送或接收);网关用于请求/回复方案(入站或出站)。有关适配器和网关的完整列表,请参阅参考文档。

Spring Cloud Stream项目建立在Spring Integration之上,其中Spring Integration用作消息驱动的微服务的引擎。

特性

  • 实施大多数企业集成模式
  • 端点Endpoint
  • 频道Channel(点对点和发布/订阅)
  • 聚合(Aggregator)
  • 过滤(Filter)
  • 变压器(Transformer)
  • 控制总线(Control Bus)
  • ...
  • 与外部系统集成
  • REST / HTTP
  • FTP/ SFTP
  • 推特(Twitter)
  • Web服务(SOAP和ReST)
  • TCP/ UDP
  • JMS
  • RabbitMQ
  • 电子邮件(Email)
  • ...
  • 该框架具有广泛的JMX支持
  • 将框架组件公开为MBean
  • 适配器从MBean获取属性,调用操作,发送/接收通知

例子

在下面的“快速入门”应用程序中,您可以看到使用相同的网关接口来调用两个完全不同的服务实现。 要构建和运行该程序,您需要如上所述的spring-integration-ws和spring-integration-xml模块。

public class Main {public static void main(String... args) throws Exception {ApplicationContext ctx =new ClassPathXmlApplicationContext("context.xml");// Simple ServiceTempConverter converter =ctx.getBean("simpleGateway", TempConverter.class);System.out.println(converter.fahrenheitToCelcius(68.0f));// Web Serviceconverter  = ctx.getBean("wsGateway", TempConverter.class);System.out.println(converter.fahrenheitToCelcius(68.0f));}
}
public interface TempConverter {float fahrenheitToCelcius(float fahren);}
<!-- Simple Service --><int:gateway id="simpleGateway"service-interface="foo.TempConverter"default-request-channel="simpleExpression" /><int:service-activator id="expressionConverter"input-channel="simpleExpression"expression="(payload - 32) / 9 * 5"/><!-- Web Service --><int:gateway id="wsGateway" service-interface="foo.TempConverter"default-request-channel="viaWebService" /><int:chain id="wsChain" input-channel="viaWebService"><int:transformerexpression="'&lt;FahrenheitToCelsius xmlns=&quot;https://www.w3schools.com/xml/&quot;&gt;&lt;Fahrenheit&gt;XXX&lt;/Fahrenheit&gt;&lt;/FahrenheitToCelsius&gt;'.replace('XXX', payload.toString())" /><int-ws:header-enricher><int-ws:soap-action value="https://www.w3schools.com/xml/FahrenheitToCelsius"/></int-ws:header-enricher><int-ws:outbound-gatewayuri="https://www.w3schools.com/xml/tempconvert.asmx"/><int-xml:xpath-transformerxpath-expression="/*[local-name()='FahrenheitToCelsiusResponse']/*[local-name()='FahrenheitToCelsiusResult']"/>
</int:chain>

这是使用Java DSL(和Spring Boot)的相同应用程序(Web服务部分)。 如果不使用Spring Boot,则需要直接使用spring-boot-starter-integration依赖项或spring-integration-java-dsl。 如果您使用Spring Integration从5.0开始,则不需要任何其他依赖项 - Java DSL包含在核心项目中:

@Configuration
@SpringBootApplication
@IntegrationComponentScan
public class Application {public static void main(String[] args) {ConfigurableApplicationContext ctx = SpringApplication.run(Application.class, args);TempConverter converter = ctx.getBean(TempConverter.class);System.out.println(converter.fahrenheitToCelcius(68.0f));ctx.close();}@MessagingGatewaypublic interface TempConverter {@Gateway(requestChannel = "convert.input")float fahrenheitToCelcius(float fahren);}@Beanpublic IntegrationFlow convert() {return f -> f.transform(payload ->"<FahrenheitToCelsius xmlns=\"https://www.w3schools.com/xml/\">"+     "<Fahrenheit>" + payload + "</Fahrenheit>"+ "</FahrenheitToCelsius>").enrichHeaders(h -> h.header(WebServiceHeaders.SOAP_ACTION,"https://www.w3schools.com/xml/FahrenheitToCelsius")).handle(new SimpleWebServiceOutboundGateway("https://www.w3schools.com/xml/tempconvert.asmx")).transform(Transformers.xpath("/*[local-name()=\"FahrenheitToCelsiusResponse\"]"+ "/*[local-name()=\"FahrenheitToCelsiusResult\"]"));}}

Spring Boot配置

Spring集成的Spring Boot自动配置

快速开始

使用Spring Initializr引导您的应用程序。

学习

文档

每个Spring项目都有自己的; 它详细解释了如何使用项目功能以及使用它们可以实现的功能。

5.1.1 CURRENT GA Reference Doc. API Doc.
5.1.2 SNAPSHOT Reference Doc. API Doc.
5.0.11 SNAPSHOT Reference Doc. API Doc.
5.0.10 GA Reference Doc. API Doc.
4.3.19 SNAPSHOT Reference Doc. API Doc.
4.3.18 GA Reference Doc. API Doc.

指南

该指南旨在在15-30分钟内完成,提供快速,实用的说明,用于为Spring的任何开发任务构建入门应用程序。

  • Integrating Data 了解如何构建使用Spring Integration获取数据,处理数据并将其写入文件的应用程序。

示例

尝试一些示例:

  • 50+ Spring Integration Samples

Spring系列学习之Spring Integration相关推荐

  1. Spring系列学习之Spring Data Pivotal GemFire数据访问

    英文原文:https://spring.io/projects/spring-data-gemfire 目录 概述 特性 快速开始 学习 文档 概述 Pivotal GemFire项目的Spring ...

  2. Spring系列学习之Spring Data Apache Geode数据访问

    英文原文:https://spring.io/projects/spring-data-geode 目录 概述 特性 快速开始 学习 文档 概述 Spring Geode项目Spring Data的主 ...

  3. Spring系列学习之Spring Cloud Stream App Starters 应用程序启动器

    英文原文:https://cloud.spring.io/spring-cloud-stream-app-starters/ 目录 Spring Cloud Stream App Starters 特 ...

  4. Spring系列学习之Spring Cloud Data Flow 微服务数据流

    英文原文:https://cloud.spring.io/spring-cloud-dataflow/ 目录 Spring Cloud数据流 概览 社区实现 快速开始 ?构建Spring Spring ...

  5. Spring系列学习之Spring Data Elasticsearch数据访问

    英文原文:https://spring.io/projects/spring-data-elasticsearch 目录 概述 特性 快速开始 学习 文档 概述 Elasticsearch的Sprin ...

  6. Spring系列学习之Spring Cloud Task App Starters 微服务任务进程可执行程序

    英文原文:http://cloud.spring.io/spring-cloud-task-app-starters/ 目录 Spring Cloud Task App Starters 特性 可用应 ...

  7. Spring系列学习之Spring Mobile

    英文原文:https://projects.spring.io/spring-mobile/ 目录 特性 快速开始 设备检测 网站偏好 设备感知视图分辨率 Sample Projects Gettin ...

  8. Spring系列学习之Spring Vault

    英文原文:https://spring.io/projects/spring-vault 目录 概述 快速开始 学习 文档 示例 概述 Spring Vault提供熟悉的Spring抽象和客户端支持, ...

  9. Spring系列学习之Spring Cloud Connectors微服务连接器

    英文原文:https://spring.io/projects/spring-cloud-connectors 概述 Spring Cloud Connectors简化了云平台(如Cloud Foun ...

最新文章

  1. python学习第四课
  2. 初学Python(二)——数组
  3. LNMP下提示File not found问题的解决方法
  4. access 查找工龄大于30_ACCESS查询操作题完整
  5. 高等数学下-赵立军-北京大学出版社-题解-练习11.2
  6. U66785 行列式求值
  7. [转载] 【python】定义带参数的装饰器,用装饰器限制函数的参数类型
  8. python 遗传算法 agv_遗传算法在AGV的路径规划中的应用
  9. 如何批量新建文件夹并命名
  10. SVN同步分支代码到主干
  11. 【福利贴】迅雷会员账号共享,每天更新
  12. 基于车载以太网的音视频传输 AVB vs RTP
  13. Activiti 流程部署方式 activi 动态部署(高级源码篇)
  14. keras的数字图像识别
  15. 录屏成gif的神器小工具 GifCam
  16. Unity教程初级Ruby‘s Adventure游戏实现带工程源码
  17. Android 原生分享文件到微信
  18. 电商平台——性能测试
  19. 尴尬世纪互联的平淡财报
  20. Linux常用开源库

热门文章

  1. foreach变异非变异_神经网络产生了一堆看起来很变异的新动物
  2. lisp语言与python_又要头秃?2020 年七大 AI 编程语言大盘点
  3. 达摩院发布2023十大科技趋势,多领域“日进一寸”式融合创新
  4. 案例:红酒数据集分析
  5. 关于facebook登录出现的问题
  6. springboot+vue+java廉租房屋维修申请系统
  7. 怪诞行为学中的一些例子
  8. iOS隐私新规如何破局?盗版SKAdnetwork可行吗?
  9. chrome 一进入调试页面就会自动打断点
  10. EtherCAT主站掉线后,如何保证目标系统免受故障影响?