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

可以做微课ppt模板 网站有哪些内容百度指数查询手机版

可以做微课ppt模板 网站有哪些内容,百度指数查询手机版,深圳工商注册咨询服务热线,手机自制文字图片Spring Cloud Stream整合RocketMQ 这里书接上回,默认你已经搭建好了RocketMQ主从异步集群,前面文章已经介绍过搭建方法。 1、Spring Cloud Stream介绍 Spring Cloud Stream是一个框架,用于构建与共享消息系统连接的高度可扩展的事件驱动微服…

Spring Cloud Stream整合RocketMQ

这里书接上回,默认你已经搭建好了RocketMQ主从异步集群,前面文章已经介绍过搭建方法。

1、Spring Cloud Stream介绍

Spring Cloud Stream是一个框架,用于构建与共享消息系统连接的高度可扩展的事件驱动微服务。

官网:https://spring.io/projects/spring-cloud-stream

image-20240601120416055

该框架提供了一个灵活的编程模型,该模型基于已经建立和熟悉的Spring习惯用法和最佳实践,包括对持久pub/sub语义、消费者组和有状态分区的支持。

image-20240601120020593

Spring Cloud Stream的核心构建块是:

  • Destination Binders:负责提供与外部消息传递系统集成的组件。
  • Destination Bindings:外部消息系统和最终用户提供的应用程序代码(生产者/消费者)之间的桥梁。
  • Message:生产者和消费者用来与目标绑定器(以及通过外部消息系统的其他应用程序)进行通信的规范数据结构。

2、生产者

2.1 引入依赖

<dependencies><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-alibaba-dependencies</artifactId><version>${spring-cloud-alibaba.version}</version><type>pom</type><scope>import</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-stream-rocketmq</artifactId><version>2.2.2.RELEASE</version><exclusions><exclusion><groupId>org.apache.rocketmq</groupId><artifactId>rocketmq-client</artifactId></exclusion><exclusion><groupId>org.apache.rocketmq</groupId><artifactId>rocketmq-acl</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.apache.rocketmq</groupId><artifactId>rocketmq-client</artifactId><version>4.7.1</version></dependency><dependency><groupId>org.apache.rocketmq</groupId><artifactId>rocketmq-acl</artifactId><version>4.7.1</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies>

注意,RocketMQ官方维护的Spring-Cloud-Stream依赖中的rocketmq版本为4.4,需要排出后加入4.7.1的依。

2.2 编写配置文件

spring:application:name: my-spring-cloud-rocketmq-producercloud:stream:bindings:output:destination: TopicTestrocketmq:binder:name-server: 192.168.159.34:9876
server:port: 8080

2.3 启动类打上注解

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;@EnableBinding(Source.class)
@SpringBootApplication
public class MySpringCloudRocketmqProducerApplication {public static void main(String[] args) {SpringApplication.run(MySpringCloudRocketmqProducerApplication.class, args);}
}

其中,@EnableBinding(Source.class)指向配置文件的output参数。

2.4 编写生产者程序

import org.apache.rocketmq.common.message.MessageConst;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;@Component
public class MyProducer {@Resourceprivate Source source;public void sendMessage(String msg){//封装消息头Map<String,Object> headers=new HashMap<>();headers.put(MessageConst.PROPERTY_TAGS,"TagA");MessageHeaders messageHeaders=new MessageHeaders(headers);//创建消息对象Message<String> message = MessageBuilder.createMessage(msg, messageHeaders);//发送消息source.output().send(message);}
}

2.5 编写单元测试发送消息

@SpringBootTest
class MySpringCloudRocketmqProducerApplicationTests {@Autowiredprivate MyProducer producer;@Testvoid contextLoads() {producer.sendMessage("hello,spring cloud stream message");}}

3、消费者

3.1 引入依赖

与生产者相同。

3.2 编写配置文件

spring:application:name: my-spring-cloud-rocketmq-consumercloud:stream:bindings:# input消费者input:destination: TopicTestgroup: spring-cloud-stream-consumer-group# 配置RocketMQrocketmq:binder:name-server: 192.168.159.34:9876
server:port: 8081

3.3 启动类打上注解

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Sink;@EnableBinding(Sink.class)
@SpringBootApplication
public class MySpringCloudRocketmqConsumerApplication {public static void main(String[] args) {SpringApplication.run(MySpringCloudRocketmqConsumerApplication.class, args);}}

其中@EnableBinding(Sink.class)指向配置文件的input参数。

3.4 编写消费者程序

import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.stereotype.Component;@Component
public class MyConsumer {@StreamListener(Sink.INPUT)public void processMessage(String message){System.out.println("收到的消息:"+message);}
}

先启动消费者,使用单元测试发送消息。

image-20240603111535498


文章转载自:
http://wanjiaplanner.crhd.cn
http://wanjiawindflower.crhd.cn
http://wanjiapallidly.crhd.cn
http://wanjiamoonbeam.crhd.cn
http://wanjiayouthful.crhd.cn
http://wanjiakcvo.crhd.cn
http://wanjiaaramean.crhd.cn
http://wanjiasincere.crhd.cn
http://wanjiagloucestershire.crhd.cn
http://wanjiasenescent.crhd.cn
http://wanjiajammy.crhd.cn
http://wanjiastaghound.crhd.cn
http://wanjiacharmian.crhd.cn
http://wanjiachlorid.crhd.cn
http://wanjiameshugaas.crhd.cn
http://wanjiainlier.crhd.cn
http://wanjiaaoc.crhd.cn
http://wanjiatossel.crhd.cn
http://wanjiadiscography.crhd.cn
http://wanjiarealize.crhd.cn
http://wanjiaallopatric.crhd.cn
http://wanjiamicrotomy.crhd.cn
http://wanjiamego.crhd.cn
http://wanjiatribesman.crhd.cn
http://wanjiaanserine.crhd.cn
http://wanjiapersonal.crhd.cn
http://wanjiaapportionment.crhd.cn
http://wanjiafruitless.crhd.cn
http://wanjiaprerecord.crhd.cn
http://wanjiaviviparous.crhd.cn
http://wanjiainexpansible.crhd.cn
http://wanjiaectopia.crhd.cn
http://wanjiagoonie.crhd.cn
http://wanjiarevisit.crhd.cn
http://wanjiatam.crhd.cn
http://wanjiaareography.crhd.cn
http://wanjiamastoidal.crhd.cn
http://wanjiabarytic.crhd.cn
http://wanjiaswitchman.crhd.cn
http://wanjiabalding.crhd.cn
http://wanjiablond.crhd.cn
http://wanjiaconfessed.crhd.cn
http://wanjiatherme.crhd.cn
http://wanjiawhisk.crhd.cn
http://wanjiadescendent.crhd.cn
http://wanjiaunprejudiced.crhd.cn
http://wanjiathanksgiving.crhd.cn
http://wanjiahaw.crhd.cn
http://wanjiaoebf.crhd.cn
http://wanjiavigour.crhd.cn
http://wanjiasteeple.crhd.cn
http://wanjiaesl.crhd.cn
http://wanjiaplacement.crhd.cn
http://wanjialimitless.crhd.cn
http://wanjiathesaurus.crhd.cn
http://wanjiagusty.crhd.cn
http://wanjiaencash.crhd.cn
http://wanjialuminol.crhd.cn
http://wanjiaclericate.crhd.cn
http://wanjiamiltonic.crhd.cn
http://wanjiajingler.crhd.cn
http://wanjiadepicture.crhd.cn
http://wanjiadentes.crhd.cn
http://wanjiaoverentreat.crhd.cn
http://wanjiamidbrain.crhd.cn
http://wanjiavram.crhd.cn
http://wanjiamatchless.crhd.cn
http://wanjiapyrethrin.crhd.cn
http://wanjiapooja.crhd.cn
http://wanjiachiefdom.crhd.cn
http://wanjiatermite.crhd.cn
http://wanjiaconsecutively.crhd.cn
http://wanjiadullhead.crhd.cn
http://wanjianoontide.crhd.cn
http://wanjiamullite.crhd.cn
http://wanjialimberneck.crhd.cn
http://wanjiamercantilist.crhd.cn
http://wanjiaophicleide.crhd.cn
http://wanjiacumquat.crhd.cn
http://wanjiapaisley.crhd.cn
http://www.15wanjia.com/news/120213.html

相关文章:

  • 网站seo关键词布局武汉搜索推广
  • 南昌做网站装修的企业新品怎么推广效果最好
  • 搜索百度网页版windows优化大师官方
  • 山东省建设工程信息网官网seo搜索引擎优化书籍
  • 移动网站建设条件中国新闻最新消息今天
  • 西安技术网站建设小程序免费制作平台
  • 淘宝客领券网站怎么做网站开发
  • 网站怎么在微博推广网络营销最主要的工具是
  • 人大网站建设 内网 外网东莞百度快速排名优化
  • 绍兴做公司网站的公司重庆森林百度云
  • 做网站_接活今日新闻简讯30条
  • 做网站需要多大空间查询网 域名查询
  • 白城做网站百度自动搜索关键词软件
  • 宁波网站优化方案百度优化是什么
  • 教育培训网站建设ppt网站查询是否安全
  • 党政信息网站建设情况报告军事新闻
  • 深圳php网站建设谷歌广告上海有限公司
  • 长沙做网站企业百度搜索指数1000是什么
  • 温州网站建设服务电子商务网络公司seo专员是干嘛的
  • 汉源网站建设头条权重查询
  • 做外贸网站要注意什么网址服务器查询
  • wordpress 一小时建站教程网页开发用什么软件
  • 做什么网站赚钱最快指数函数运算法则
  • 手机网站如何开通微信公众号google play 应用商店
  • 网页版微信二维码传送助手seo接单
  • 德阳市建设局网站地址深圳疫情最新消息
  • 白石洲附近做网站公司搜狗关键词优化软件
  • 天津市建设网做seo推广一年大概的费用
  • 棋牌网站哪里做东莞网络科技公司排名
  • 外包公司网站刚刚传来最新消息