spring integration 概述

Spring Integration

Extends the Spring programming model to support the well-known Enterprise Integration Patterns. Spring Integration enables lightweight messaging within Spring-based applications and supports integration with external systems via declarative adapters. Those adapters provide a higher-level of abstraction over Spring‘s support for remoting, messaging, and scheduling. Spring Integration‘s primary goal is to provide a simple model for building enterprise integration solutions while maintaining the separation of concerns that is essential for producing maintainable, testable code.

spring integration 将spring 编程模型扩展成支持广为人知的"企业集成模式"。spring integration,通过可声明的适应器,使得在spring应用程序和外部系统的支持集成上建立轻量级的消息成为可能。那些适应器在spring对远程、消息、日程安排方面提供了高层次的抽象。spring integration的主要目标是提供一个简单的模型来构建“企业集成的解决方案”,同时对那些产生可持续、可测试代码非常重要的关注点维持隔离。

Introduction

Using the Spring Framework encourages developers to code using interfaces and use dependency injection (DI) to provide a Plain Old Java Object (POJO) with the dependencies it needs to perform its tasks. Spring Integration takes this concept one step further, where POJOs are wired together using a messaging paradigm and individual components may not be aware of other components in the application. Such an application is built by assembling fine-grained reusable components to form a higher level of functionality. WIth careful design, these flows can be modularized and also reused at an even higher level.

In addition to wiring together fine-grained components, Spring Integration provides a wide selection of channel adapters and gateways to communicate with external systems. Channel Adapters are used for one-way integration (send or receive); gateways are used for request/reply scenarios (inbound or outbound). For a full list of adapters and gateways, refer to the reference documentation.

The Spring XD project builds on Spring Integration, where Spring Integration modules are assembled into an XD Stream.

介绍

  使用spring 框架使得开发者更有勇气使用接口来编程、使用依赖注入来为一个“简单的java对象(POJO)”提供它本身执行任务时需要的一些依赖对象。spring integrationj将这种概念更深了一步:被一个消息范例和一些个体元件接通的POJOs可能并不会意识到应用中的其它元件。这样的一个应用被可装配的细颗粒的可重用的元件创建来形成一个更高级别的功能。通过精心的设计,这些流量可以被模块化,甚至可以被重用在一个更高的级别。

  除了接通细颗粒的元件外,spring integration在channel adapters 和 同外部系统交互gateways方面还提供了一个广泛的选择。channel adapters 被用来做单程的集成(发送或者接收);gateways 被用在请求/应答 场景(呼入或呼出)。关于完整的adapters和gateways列表,参考相应文档。

  Spring XD 项目构建在Spring integration上,spring integration 组件被装配进 一个 XD流中。

Features

  • Implementation of most of the Enterprise Integration Patterns

    • Endpoint
    • Channel (Point-to-point and Publish/Subscribe)
    • Aggregator
    • Filter
    • Transformer
    • Control Bus
    • ...
  • Integration with External Systems
    • ReST/HTTP
    • FTP/SFTP
    • Twitter
    • WebServices (SOAP and ReST)
    • TCP/UDP
    • JMS
    • RabbitMQ
    • Email
    • ...
  • The framework has extensive JMX support
    • Exposing framework components as MBeans
    • Adapters to obtain attributes from MBeans, invoke operations, send/receive notifications

特征:

  1.多数“企业集成模式”的实现:

  • Endpoint :端点
  • Channel (Point-to-point and Publish/Subscribe) :通道(点对点和发布/订阅)
  • Aggregator:聚合器
  • Filter:过滤器
  • Transformer:转换器
  • Control Bus : 控制总线
  • ……

  2.同外部系统的集成:

  • ReST/HTTP
  • FTP/SFTP
  • Twitter
  • WebServices (SOAP and ReST)
  • TCP/UDP
  • JMS
  • RabbitMQ
  • Email
  • ...

 3.这个框架提供扩展到jmx的支持。(Java Management Extensions,即Java管理扩展,是一个为应用程序、设备、系统等植入管理功能的框架。)

  • 将框架组件作为MBeans暴露。(管理构件(MBean:在JMX规范中,管理构件定义如下:它是一个能代表管理资源的Java对象,遵从一定的设计模式,还需实现该规范定义的特定的接口。该定义了保证了所有的管理构件以一种标准的方式来表示被管理资源。)
  • Adapters 从MBeans获得属性,调用操作,发送/接收通知。

3.这个框架提供扩展到jmx的支持。(Java Management Extensions,即Java管理扩展,是一个为应用程序、设备、系统等植入管理功能的框架。)

 

Quick Start

The recommended way to get started using spring-integration in your project is with a dependency management system – the snippet below can be copied and pasted into your build. Need help? See our getting started guides on building with Maven and Gradle

在你的项目中开始使用spring-integration,推荐的方式是使用一个依赖管理系统:下面的代码片段可以被拷贝粘贴到你的系统中。若需要帮助,参考Maven 和Gradle的getting started文档。

<dependencies>
    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-core</artifactId>
        <version>4.0.3.RELEASE</version>
    </dependency>
</dependencies>

In the following "quick start" application you can see that the same gateway interface is used to invoke two completely different service implementations. To build and run this program you will need the spring-integration-ws and spring-integration-xml modules as described above.

在下面的“快速开始”应用中,你可以看到同样的gateway 接口被用来调用两个完全不同的服务实现。构建和运行这个程序,你需要上面已经描述过的spring-integration-ws 和sping-integration-xml组件。

public class Main {

    public static void main(String... args) throws Exception {
        ApplicationContext ctx =
            new ClassPathXmlApplicationContext("context.xml");
        // Simple Service
        TempConverter converter =
            ctx.getBean("simpleGateway", TempConverter.class);
        System.out.println(converter.fahrenheitToCelcius(68.0f));
        // Web Service
        converter  = 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:transformer
       expression="‘&lt;FahrenheitToCelsius xmlns=‘‘http://tempuri.org/‘‘&gt;&lt;Fahrenheit&gt;XXX&lt;/Fahrenheit&gt;&lt;/FahrenheitToCelsius&gt;‘.replace(‘XXX‘, payload.toString())" />
    <int-ws:header-enricher>
        <int-ws:soap-action value="http://tempuri.org/FahrenheitToCelsius"/>
    </int-ws:header-enricher>
    <int-ws:outbound-gateway
        uri="http://www.w3schools.com/webservices/tempconvert.asmx"/>
    <int-xml:xpath-transformer
        xpath-expression="/*[local-name()=‘FahrenheitToCelsiusResponse‘]/*[local-name()=‘FahrenheitToCelsiusResult‘]"/>
</int:chain>
时间: 2024-08-01 21:53:56

spring integration 概述的相关文章

Spring Integration概述

1.   Spring Integration概述 1.1     背景 Spring框架的一个重要主题是控制反转.从广义上来说,Spring处理其上下文中管理的组件的职责.只要组件减轻了职责,它们同时也被简化了.例如,依赖注入降低了定位和创建组件间依赖的耦合性.同样地,面向方面编程通过模块化可重复利用方面,将业务组件和通用的横切面关注点解耦.在这样的情况下,最终的结果是系统更容易测试,理解,维护和扩展. 此外,Spring框架和相关工具集提供一个优秀的构建企业级应用的编程模型.这个模型的一致性

Spring Cloud 概述

1. Spring Cloud 引言 首先我们打开spring 的官网:https://spring.io/ 我们会看到这样一张图片 这个图片告诉我们,开发我们的应用程序就像盖楼一样, 首先我们需要搭建Spring Boot, 在此基础上可以搭建Spring Cloud,再往上面可以搭建Spring Cloud Data Flow 2.Spring Cloud 概述 协调:分布式系统简化 构建分布式系统不需要很复杂且容易出错. Spring Cloud为最常见的分布式系统模式提供了简单易用的编程

Spring Integration

The Cafe Sample(小卖部订餐例子) 小卖部有一个订饮料服务,客户可以通过订单来订购所需要饮料.小卖部提供两种咖啡饮料 LATTE(拿铁咖啡)和MOCHA(摩卡咖啡).每种又都分冷饮和热饮 整个流程如下: 1.有一个下订单模块,用户可以按要求下一个或多个订单. 2.有一个订单处理模块,处理订单中那些是关于订购饮料的. 3.有一个饮料订购处理模块,处理拆分订购的具体是那些种类的饮料,把具体需要生产的饮料要求发给生产模块 4.有一个生产模块,进行生产. 5.等生成完成后,有一个订单确认模

Spring Integration - 自动轮询发送手机短信

Spring Integration 配置 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.sprin

深入Spring事务(一)Spring事务概述

Spring事务概述 一.事务概述 事务首先是一系列操作组成的工作单元,该工作单元内的操作是不可分割的,即要么所有操作都做,要么所有操作都不做,这就是事务. 事务必需满足ACID(原子性.一致性.隔离性和持久性)特性,缺一不可: 原子性(Atomicity):即事务是不可分割的最小工作单元,事务内的操作要么全做,要么全不做: 一致性(Consistency):在事务执行前数据库的数据处于正确的状态,而事务执行完成后数据库的数据还是处于正确的状态,即数据完整 性约束没有被破坏:如银行转帐,A转帐给

【代码审计】Spring Integration Zip不安全解压(CVE-2018-1261)漏洞分析

1.漏洞相关信息 漏洞名称:Spring Integration Zip不安全解压 漏洞编号:CVE-2018-1261 漏洞描述:在spring-integration-zip.v1.0.1.RELEASE之前的版本中,恶意用户通过在压缩文件中构造包含有特定文件名称的文件(受影响文件格式有bzip2, tar, xz, war, cpio, 7z),应用程序使用spring-integration-zip进行解压时,会导致跨目录任意写入文件漏洞的攻击.进而有可能被Getshell,远程控制.

Spring IOC 概述

Spring IOC 概述 IOC(Inversion of Control) 控制反转,也叫 DI(D_ependency injection_) 依赖注入.是一种设计思想.不过我并不同意所谓反转的说法,因为没有谁规定什么方式就是“标准”的,如果我把IOC作为“标准”,IOC就是“标准”自身,何来反转?不过我行文也是沿用官方的说法,使用IOC描述这个技术 IOC其实是一种组装的思想,最简单理解 IOC 的方法,就是我们的组装电脑. 主板,硬盘,显卡,CPU厂商们先定义好一个个插口. 然后主板厂

spring DefaultListableBeanFactory 概述

有人说,DefaultListableBeanFactory是spring的发动机,其实重要性不为过.TA的整体类图如下: 这里先概述接口部分: BeanFactory是Spring的最根的接口,类的工厂接口.HierarchicalBeanFactory接口是在继承BeanFactory的基础上,实现BeanFactory的父子关系. AutowireCapableBeanFactory接口是在继承BeanFactory的基础上,实现Bean的自动装配功能 ListableBeanFactor

01 - spring mvc 概述及配置DispatcherServlet

1.Spring mvc 基于model2实现,整体框架流程如(图片来自百度): ①web容器接收到http请求,若匹配DispatcherServlet的请求映射路径(web.xml),则容器会交给DispatcherServlet处理. ②DispatcherServlet根据请求的信息及handlerMapping(类似路由功能)的配置找到处理请求的Handler. ③Handler adapter对handler进行封装,使用统一的方法对Handler方法进行调用 ④处理器完成业务逻辑后