毕业设计外文文献—Spring 集成带有Spring Boot的Spring流.docx

上传人:太** 文档编号:52317768 上传时间:2022-10-22 格式:DOCX 页数:15 大小:234.15KB
返回 下载 相关 举报
毕业设计外文文献—Spring 集成带有Spring Boot的Spring流.docx_第1页
第1页 / 共15页
毕业设计外文文献—Spring 集成带有Spring Boot的Spring流.docx_第2页
第2页 / 共15页
点击查看更多>>
资源描述

《毕业设计外文文献—Spring 集成带有Spring Boot的Spring流.docx》由会员分享,可在线阅读,更多相关《毕业设计外文文献—Spring 集成带有Spring Boot的Spring流.docx(15页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、附录A外文翻译一原文局部F. Gutierrez, Pro Spring Boot 2, s:/doi.org/! 0.1007/978-1 -4842-3676-5_l ISpring Integration and Spring Cloud Stream with Spring BootIn this chapter, I show you one of the best integration frameworks for the Java community: the Spring Integration project, which is based on the Spring Fr

2、amework. I also present the Spring Cloud Stream, which is based on Spring Integration. It creates robust and scalable event- driven microservices connected to shared messaging systems-all done with Spring Boot.If we take a look at software development and business needs, as a developer or an archite

3、ct, we are always looking at how to integrate components and systems, either internal or external to our architecture, and probe what is fully functional, highly available, and easy to maintain and enhance.The following are the main uses cases that developers or architects typically face. Creating a

4、 system that does a reliable file transfer or file analysis. Most of the applications out there need to read information from a file and then process it, so we need to create robust file systems that save and read data but also share and deal with the size of the files. The ability to use data in a

5、shared environment where multiple clients (systems or users) need access to the same database or the same table and do operations and deal with inconsistency, duplication, and more. Remote access to different systems, from executing remote procedures, to sending a lot of information. We always want

6、to have this in real time and in an asynchronous way. The ability to get a response as fast as possible without forgetting that the remote system always needs to be reachable; in other words, have the fault tolerance and high availability required. Messaging-from a basic internal call to billions of

7、 messages per second to reniole brokers. Normally, we do messaging in an asynchronous way, so we need to deal with concurrency, multithreading, speed (network latency), high availability, fault tolerance, and so forth.How can we solve or implement all of these use cases? Almost 15 years ago, softwar

8、eRemember that a message is about headers and payload, which is why we get the GenericMessage class with a payload where the final message is BUY MILK TODAY and headers that include the ID and the timestamp. This is the result of applying a filter and transforming the message.附录B外文翻译一译文局部Spring 集成带有

9、 Spring Boot 的 Spring 流在本章中,我向大家展示了 java社区最好的集成框架之一:基于Spring框架的Spring 集成工程。我还介绍了基于Spring集成的Spring流。它创立了连接到共享消息系统的强大 和可扩展的事件驱动的微服务一一所有这些都是用Spring Boot完成的。如果我们看看软件开发和业务需求,作为一个开发者或建筑师,我们总是在考虑如何集 成组件和系统,无论是内部的还是外部的,我们的架构,并探索什么是完全功能的,高度可 用的,易于维护和增强。以下是开发者或架构师通常会面对的主要用例。* 创立一个能够进行可靠的文件传输或文件分析的系统。大局部的应用程序都

10、需要从文件,然后处理它,所以我们需要创立健壮的文件系统保存和读取数据,并共享和处理文件的大小。* 在多个共享环境中使用数据的能力客户(系统或用户)需要访问同一数据库或做同样的操作和处理不一致的问题,重复,还有更多。* 从执行远程访问到不同系统程序,发送大量信息。我们一直想拥有这在实时和异步的方式。能够在不忘记远程系统总是需要可到达的情况下尽快得到响应; 换句话说,具有所需的容错性和高可用性。* 短信一一从基本的内部通话到每秒数十亿条短信,再到远程经纪人。通常,我们用异 步方式进行消息传递,因此我们需要处理并发、多线程、速度(网络延迟)、高可用性、容 错性等问题。我们如何解决或实现所有这些用例?

11、大约15年前,软件工程师GregorHohpe和Bobby Woolf撰写了企业集成模式:设计、构建和部署消息传递解决方案(addison-wesley, 2003 年)。这本书公开了解决我提到的用例所需的所有消息模式。它可以更好地理解系统如何相 互连接和工作,以及如何创立一个具有应用程序体系结构、面向对象设计和面向消息的健壮 集成系统。在下面的章节中,我将使用Spring框架中的Spring集成工程向您展示其中的一些模式。Spring集成底漆Spring集成是实现企业集成解决方案的一个简单模型。它方便了 Spring启动应用程序 中的异步和消息驱动。它实现了创立企业、健壮和可移植的集成解决方

12、案的所有企业集成模 式。该Spring集成工程提供了一种方法,使组件松散耦合模块化和可测试性。它有助于在 业务和集成逻辑之间强制别离关注点。Spring集成公开了以下主要组件。信息。这是任何java对象的通用包装器。它由头和 有效载荷组成。标头通常有重要的信息,如id、时间戳、相关id和返回地址;当然,您可 以添加自己的信息。有效负载可以是任何类型的数据,从字节数组到自定义对象。您可以 在.org中的春季消息模块中找到它的定义。Spring框架。消息包。public interface Message T getPayload();MessageHeaders getHeaders();)正如

13、你所看到的,没有什么花哨的定义。 留言频道。管道和过滤器架构,非常类似于在unix系统中使用的命令。要使用它,你 需要有生产者和消费者;生产者将消息发送到消息通道,消费者接收它(见下列图)。Channel此消息通道遵循消息传递模式,如点对点和发布/订阅模型。Spring集成为消费者提供 了一些消息通道,如可传播的通道(允许您在队列中拥有缓冲消息)或可订阅的通道。 信息终点。将应用程序代码连接到消息传递框架的筛选器。这些端点大多是企业集成模式的实现。 过滤。消息筛选器决定何时将消息传递到输出通道。 变压器。消息转换器修改消息的内容或结构并将其传递到输出通道。 路由器。消息路由器根据规那么决定做什

14、么和向何处发送消息。这些规那么可以在标头中, 也可以在同一个有效载荷中。这个消息路由器有很多模式可以应用。我至少会给你看其中一 个。拆分器。消息拆分器接受消息(输入通道),然后拆分并返回新的多个消息(输出通道)。 服务激活器。这是一个端点,通过接收消息(输入通道)并处理它来充当服务。它既 可以结束集成的流,也可以返回相同的消息或一个全新的消息(输出通道)。八聚合器。此消息端点接收到多个消息(输入通道);它将它们合并到一个新的单一消 息(基于发布策略)中并发送出去(输出通道)。 通道适配器。这是一个特定的端点,将消息通道连接到其他系统或传输。Spring集成 提供入站或出站适配器。在需要响应的情

15、况下,它提供网关适配器。你看,这些是最常用的。 为什么?如果您的解决方案是要连接到rabbitmq、jms、ftp、一个文件系统、 或任何其他 技术,那么Spring集成就可以在不对任何客户端进行编码的情况下连接到它。如果你对这项技术感兴趣,我建议MarkLui博士(apress, 2011年)写一本关于Spring 集成和消息模式、消息通道、适配器等等的新书。在下一节中,我将向您展示一些组件和模式,这些组件和模式足以让您开始。编程Spring集成有了 Spring集亦 有几种方法来配置所有的组件(消息、消息通道和消息端点):xml、 javaconfig类、注释和新的集成dsl。带有Spri

16、ng集成的todo应用程序让我们从著名的todo应用程序开始,立即使用Spring集成。你可以从头开始,也可以 在接下来的章节里学习你需要做的事情。如果你是从零开始,那么你可以去Spring初始化 ( s:/start)。spring.io),并在字段中添加以下值。 小组讨论 艺术品:整合 名字:整合 包装名称:来吧依赖:Spring整合,龙目您可以选择maven或gladle作为工程类型。然后您可以按下生成的工程按钮,该按钮 可以下载zip文件。解压缩并导入您最爱的代码中的工程(见下列图)。从依赖关系中可以看出,我们现在使用的是Spring积分。您可以重用或复制托多类(见 清单11-1)。清

17、单 package com.aprcss.todo.domain;import lombok.Data;import java.time.LocalDateTime; import java.util.UUlD;Datapublic class ToDo private String id;private String description; private LocalDateTime created; private LocalDateTime modified; private boolean completed;public ToDo()this.id = UUID.randomUUI

18、D().toString(); this.created = LocalDateTime.now(); this.modified =LocalDateTime.now();)public ToDo(String description) this();this.description = description;)public ToDo(String description,boolean completed)( this(description);this pleted = completed;)清单11-1显示你的知名ToD。class。这没什么新鲜的。接下来,让我们创立一个有第 一个使

19、用dsl的Spring集成流的Todo集成类(参见清单11-2) o清单 package com.apress.todo.integration;import com.apress.todo.domain.ToDo;import org.springframcwork.contcxt.annotation.Bcan;import org.springframework.context.annotation.Configuration;import org.springframework.integration.channel.DirectChannel;import org.springfra

20、mework.integration.config.Enablelntegration;import org.springframework.integration.dsl.IntegrationFlow;import org.springframework.integration.dsl.IntegrationFlows;import org.springframework.integration.dsl.channel.MessageChannels;EnableIntegrationConfigurationpublic class ToDoIntegration Beanpublic

21、DirectChannel input()return MessageChannels.direct().get();)Beanpublic IntegrationFlow simp!eFlow() return IntegrationFlows.from(input().filter(ToDo.class, ToDo:isCompleted).transform(ToDo.class,toDo - toDo.getDescription().toUpperCase().handle(System.out:println).get();)清单11-2是一个基本例子。此例如接收来自输入通道(一个

22、todo实例)的消息,如果 仅完成该tod。,那么筛选此消息,然后通过提升描述来转换该消息,并通过在控制台上打印来 处理该消息。所有这些都被称为集成流。但让我们更深入地看看里面。 积分流。将dsl公开为bean (需要有一个bean注释)。这个班是工厂积分流生成器并定义积分的流。它注册所有的组件,如消息通道、端点等。 整合流。该类公开了一个帮助构建集成流的流利api。它很容易合并端点,如转换,过 滤,处理,拆分,聚合,路由,桥。使用这些端点,可以使用任何java8 (和以上)Lambda 表达式作为参数。 来自。这是一个重裁的方法,您通常在这里传递消息源;在这种情况下,我们调用的 输入方法通过

23、消息机构流畅的api返回一个直接通道实例。 过滤。这种超载的方法使消息传递者满员。我不知道。如果选择器接受消息,那么将消息委托给消息选择器,该消息选择器将消息发送到筛选器 的输出通道。 变革。这个方法可以接收到一个Lambda表达式,但实际上接收到的是通用变压器 input.send( MessageBuilder.withPayload(new ToDo(nbuy milk today1,true);)清单11-3显示应用程序转运器Bean,应用程序启动时在那里执行(参见注入消息机制 在Todo集成类中声明的那个)。这个方法是使用一个消息生成器类,该类提供了一个创 建消息的流利api。在这种

24、情况下,类使用有效负载方法创立一个新的dodo实例,标记为已 完成。现在是时候运行我们的应用程序。如果您运行它,应该会看到与以下输出相似的东西。 INFO 39319- main o.s.i.e.EventDrivenConsumer: started simpleFlow.org.springframework.integration.config.ConsumerEndpointFactoryBean#2INFO 39319- main c.a.todo.TodoIntegrationApplication : StartedTodoIntegrationApplication in 0.

25、998 seconds (JVM running for 1.422)GenericMessage payload=BUY MILK TODAY, headers=id= 请记住,一个消息是关于标头和有效载荷的,这就是为什么我们得到了带有有效载荷的 一般消息类,最终消息是“BUY MILK TODAY”,标头包括id和时间戳。这是应用过滤器 和转换消息的结果。engineers Gregor Hohpe and Bobby Woolf wrote Enterprise Integration Patterns: Designing, Building and Deploying Messagi

26、ng Solutions (Addison-Wesley, 2003). This book exposes all the messaging patterns needed to solve the use cases that I mentioned. It gives a better understanding on how systems interconnect and work, and how you can create a robust integration system with application architecture, object-oriented de

27、sign, and message-oriented.In the following sections, ril show you some of these patterns using the Spring Integration project from the Spring Framework.Spring Integration PrimerSpring Integration is a simple model for implementing enterprise integration solutions. It facilitates the asynchronous an

28、d message-driven within a Spring Boot application. It implements all the enterprise integration patterns for creating enterprise, robust, and portable integration solutions.The Spring Integration project offers a way to have components that are loosely coupled for modularity and testability. It help

29、s to enforce the separation of concerns between your business and integration logic.Spring Integration exposes the following main components. Message. This is a generic wrapper for any Java object. It consists of headers and a payload. The headers normally have important information like ID, timesta

30、mp, correlation ID, and return address; and of course, you can add your own. The payload can be any type of data, from an array of bytes to custom objects. You can find its definition in the spring-messaging module in the org. springframework.messaging package.public interfaceMessage TgetPayload();M

31、essageHeaders getHeaders();)As you can see, theres nothing fancy in the definition. Message channel. Pipes and filters architecture, very similarto the command you use in a UNIX system. To use it, you need to have producers and consumers; the producer sends the message to the message channel and a c

32、onsumer receives it (see Figure 11-1).Producersend(Message)Channelreceive()ConsumerFigure 11-1. Message channelThis message channel follows messaging patterns, such as the Point-to-Point and Publish/Subscribe models. Spring Integration offers several message channels, like pollable channels (that al

33、lows you to have buffering messages within a queue) or subscribable channels for the consumers. Message endpoint. A filter that connects the application code to the messaging framework. Most of these endpoints are part of theEnterprise Integration Patterns implementations. Filter. A message filter d

34、etermines when a message should be passed to the output channel. Transformer. A message transformer modifies the content or structure of a message and passes it to the output channel. Router. A message router decides what to do and where to send the message based on rules. These rules can be in the

35、headers or in the same payload. This message router has many patterns that can be applied. Til show you at least one of them. Splitter. A message splitter accepts a message (input channel), and it splits and returns new multiple messages (output channel). Service activator. This is an endpoint that

36、acts as a service by receiving a message (input channel) and processes it. It can either end the flow of the integration or it can return the same message or an entirely new one (output channel). Aggregator. This message endpoint received multiple messages (input channel); it combines them in a new

37、single message (base on a release strategy) and sends it out (output channel). Channel adapters. This is a particular endpoint that connects a message channel to other systems or transports. Spring Integration offers inbound or outbound adapters. Where a response is required, it offers a gateway ada

38、pter. You see that these are themost commonly used. Why? If your solution is looking to connect to RabbitMQ, JMS, FTP, a File System, or any other technology, Spring Integration has the adapter to connect to it without you coding any client.It would take a whole new book to write about Spring Integr

39、ation and message patterns, messaging channels, adapters, and more, but if you are interesting in this technology, I recommend Pro Spring Integration by Dr. Mark Lui (Apress, 2011).In the next section, Ill show you some of the components and patterns, which are enough to get you started.Programming

40、Spring IntegrationWith Spring Integration, there are several ways to configure all the components (message, message channel and message endpoints): XML, JavaConfig classes, annotations, and the new Integration DSL.ToDo App with Spring IntegrationLefs start with the well-known ToDo App and use Spring

41、 Integration right away. You can start from scratch or you can follow along in the next sections to learn what you need to do. If you are starting from scratch, then you can go to Spring Initializr (.spring.io) and add the following values to the fields. Artifact: todo-integration Name: todo-integra

42、tion Dependencies: Spring Integration, LombokYou can select either Maven or Gradle as the project type. Then you can press the Generate Project button, which downloads a ZIP file. Uncompress it and import the project in your favorite IDE (see Figure 11-2).SPRING INITIALIZRbootstrap your application

43、nowGenerate a Maven Project : /y j t h Java : and Spring Boot DependenciesAdd Spring Boot Starters and dependencies to your applicationSearch for dependenciesWeb, Security, JPA, Actuator, Devtools.Selected DependenciesSpring Integration I LombokProject MetadataArtifact coordinatesGroupArtifacttodo-i

44、ntegrationNametodo-integrationDescriptionDemo project for Spring BootPackage Namecom.apresstodoPackagingJarJava Version8Too many options? Swtct back to Lhe srnple version.Generate Project 族 +。Figure 112 Spring InitializrAs you can see from the dependencies, we are now using Spring Integration. You c

45、an reuse or copy the T0D0 class (see Listing 11-1).Listing 11-1.package com.apress.todo.domain;import lombok.Data;import java.time.LocalDateTime;import java.util.UUID;Datapublic class ToDo private String id;private String description; privateLocalDateTime created; private LocalDateTime modified; private boolean completed;public ToDo()this.id = UUID.randomUUID().toString();

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 应用文书 > 解决方案

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com