当前位置: 首页 > news >正文

做网站需要了解哪些知识免费建站软件排行榜

做网站需要了解哪些知识,免费建站软件排行榜,做电影网站要多少钱,电商设计教程文章目录 概述**核心概念****使用场景****快速入门**1. 添加依赖2. 配置 Binder3. 定义消息通道4. 发送和接收消息5. 运行应用 **高级特性****优点****适用场景** 概述 Spring Cloud Stream 是一个用于构建消息驱动微服务的框架#xff0c;它基于 Spring Boot 和 Spring Inte… 文章目录 概述**核心概念****使用场景****快速入门**1. 添加依赖2. 配置 Binder3. 定义消息通道4. 发送和接收消息5. 运行应用 **高级特性****优点****适用场景** 概述 Spring Cloud Stream 是一个用于构建消息驱动微服务的框架它基于 Spring Boot 和 Spring Integration提供了与消息中间件如 Kafka、RabbitMQ 等的集成。通过 Spring Cloud Stream开发者可以轻松地将消息传递机制引入到微服务架构中而无需直接与底层消息中间件交互。 核心概念 Binder Binder 是 Spring Cloud Stream 的核心组件用于与消息中间件如 Kafka、RabbitMQ集成。它抽象了底层消息中间件的细节开发者只需通过配置即可切换不同的消息中间件。例如spring-cloud-starter-stream-kafka 或 spring-cloud-starter-stream-rabbit。 Binding Binding 是消息通道Channel与消息中间件之间的桥梁。分为 输入绑定Input Binding 和 输出绑定Output Binding 输入绑定用于接收消息。输出绑定用于发送消息。 Message Channel 消息通道是 Spring Cloud Stream 中的抽象概念用于发送和接收消息。常用的通道接口 MessageChannel用于发送消息。SubscribableChannel用于订阅消息。 Message 消息是 Spring Cloud Stream 中的基本数据单元包含 Payload消息体 和 Headers消息头。 使用场景 事件驱动架构通过消息传递实现服务之间的解耦。数据流处理实时处理和分析数据流。异步通信提高系统的响应速度和吞吐量。 快速入门 1. 添加依赖 在 pom.xml 中添加 Spring Cloud Stream 和 Binder 的依赖以 Kafka 为例 dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-stream-kafka/artifactId /dependency2. 配置 Binder 在 application.yml 中配置 Kafka Binder spring:cloud:stream:bindings:input:destination: myTopicgroup: myGroupoutput:destination: myTopickafka:binder:brokers: localhost:90923. 定义消息通道 通过接口定义输入和输出通道 import org.springframework.cloud.stream.annotation.Input; import org.springframework.cloud.stream.annotation.Output; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.SubscribableChannel;public interface MyProcessor {String INPUT input;String OUTPUT output;Input(INPUT)SubscribableChannel input();Output(OUTPUT)MessageChannel output(); }4. 发送和接收消息 编写服务类发送和接收消息 import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.stream.annotation.EnableBinding; import org.springframework.cloud.stream.annotation.StreamListener; import org.springframework.messaging.support.MessageBuilder; import org.springframework.stereotype.Service;EnableBinding(MyProcessor.class) Service public class MyService {Autowiredprivate MyProcessor processor;// 发送消息public void sendMessage(String message) {processor.output().send(MessageBuilder.withPayload(message).build());}// 接收消息StreamListener(MyProcessor.INPUT)public void receiveMessage(String message) {System.out.println(Received: message);} }5. 运行应用 启动 Spring Boot 应用后消息将通过 Kafka 发送和接收。 高级特性 消息分区 通过配置分区策略将消息分发到不同的分区中。示例配置spring:cloud:stream:bindings:output:destination: myTopicproducer:partition-key-expression: headers[partitionKey]partition-count: 3消息分组 通过分组确保同一组内的消息只被一个消费者实例处理。示例配置spring:cloud:stream:bindings:input:destination: myTopicgroup: myGroup消息重试和错误处理 通过配置重试策略和错误通道处理消息消费失败的情况。示例配置spring:cloud:stream:bindings:input:destination: myTopicconsumer:max-attempts: 3back-off-initial-interval: 1000多 Binder 支持 支持同时使用多个消息中间件如 Kafka 和 RabbitMQ。示例配置spring:cloud:stream:binders:kafkaBinder:type: kafkaenvironment:spring:kafka:bootstrap-servers: localhost:9092rabbitBinder:type: rabbitenvironment:spring:rabbitmq:host: localhostport: 5672优点 简化消息中间件集成通过 Binder 抽象屏蔽底层消息中间件的差异。灵活的配置支持多种消息中间件和高级特性如分区、分组、重试等。与 Spring 生态无缝集成基于 Spring Boot易于与其他 Spring 组件如 Spring Data、Spring Security集成。 适用场景 需要解耦的微服务架构。实时数据流处理。异步任务处理。 通过 Spring Cloud Stream开发者可以快速构建高效、可靠的消息驱动微服务同时享受 Spring 生态的强大支持。
http://www.w-s-a.com/news/734233/

相关文章:

  • 营销型网站建设运营企业宣传网页设计
  • 建设银行官方网站网址sem搜索
  • 简述建设网站的具体步骤网络建设方案ppt
  • 自建门户网站建设工程质量监理协会网站
  • 为企网站版面设计经历了哪几个阶段
  • 如何直到网站是用什么模板做的怎么在外贸公司拿订单
  • 网站专题制作酒店网站建设考虑的因素
  • 苏州招聘网站建设潍坊网站建设wfxtseo
  • 手机网站特效做互联网平台要多少钱
  • 做网站广告推广平台旅游网站后台管理系统
  • ppt模板下载免费素材网站php网站开发平台下载
  • 网站推广策划报告航空航天可以做游戏可以视频约会的网站
  • 云南建设学院的网站划分切片来做网站
  • 建设视频网站需要什么知识辽阳建设网站
  • 提供o2o网站建设打扑克网站推广软件
  • 制作简单门户网站步骤中国建设局网站查询
  • 漳州专业网站建设网站建设的面试要求
  • 有哪些网站是封面型汕头网站上排名
  • 自动优化网站软件没有了做的新网站做百度推广怎么弄
  • 高陵县建设局网站商标查询网站
  • 郑州建设网站哪家好东莞网络公司排行榜
  • 成都网站开发费用做行程的网站
  • 做地铁建设的公司网站手机网站首页布局设计
  • 福建亨立建设集团有限公司网站搜狗网页游戏大厅
  • 设计网站musil访问量大的网站选择多少流量的服务器何时
  • 公司网站包括哪些内容新网站怎样做外链
  • 淘宝宝贝链接怎么做相关网站广州好蜘蛛网站建设
  • 长春网站制作网页博山区住房和城乡建设局网站
  • 云南大学网站建设解析到网站怎样做
  • 网站维护的要求包括锦溪网站建设