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

程序开发过程的四个步骤廊坊百度关键词优化

程序开发过程的四个步骤,廊坊百度关键词优化,如何在网上推广农产品,遵义在线网站建设Spring Cloud Stream 是一个用来为微服务应用构建消息驱动能力的框架。它可以基于 Spring Boot 来创建独立的、可用于生产的 Spring 应用程序。Spring Cloud Stream 为一些供应商的消息中间件产品提供了个性化的自动化配置实现,并引入了发布-订阅、消费组、分区这三…

        Spring Cloud Stream 是一个用来为微服务应用构建消息驱动能力的框架。它可以基于 Spring Boot 来创建独立的、可用于生产的 Spring 应用程序。Spring Cloud Stream 为一些供应商的消息中间件产品提供了个性化的自动化配置实现,并引入了发布-订阅、消费组、分区这三个核心概念。简单的说,Spring Cloud Stream本质上就是整合了Spring Boot和Spring Integration,实现了一套轻量级的消息驱动的微服务框架。

     目前 Spring Cloud Stream只支持 RabbitMQ 和 Kafka 的自动化配置。

     Spring Cloud Stream 提供了 Binder (负责与消息中间件进行交互),我们则通过 inputs 或者 outputs 这样的消息通道与 Binder 进行交互。Binder 绑定器是 Spring cloud Stream 中一个非常重要的概念,实现了应用程序和消息中间件之间的隔离,同时我们也可以通过应用程序实现,消息中间件之间的通信。在我们的项目的可以继承多种绑定器,我们可以根据不同特性的消息使用不同的消息中间件。Spring Cloud Stream 为我们实现了 RabbitMQ 和Kafka 的绑定器。如果你想使用其他的消息中间件需要自己去实现绑定器接口.

在 SpringCloudStream 3.x 版本前是通过 @StreamListener 和 @EnableBinding 进行消息的发送和消费的,springCloudStream 3.x 版本后 @StreamListener 和 @EnableBinding 都打上了@Deprecated 注解,不建议使用了;后续的版本更新中替换成函数式的方式实现。

既然通过四大函数式接口的方式替换了注解的方式 那么该如何进行绑定呢?

通过 spring.cloud.stream.function.definition:名称的方式进行绑定 公开 topic。

不管是创建 Consumer 还是 Supplier 或者是 Function Stream都会将其的 方法名称 进行 一个 topic拆封 和 绑定 假设 创建了一个 Consumer< String > myTopic 的方法,Stream 会将其 拆分成 In 和 out 两个通道:

  • 输入 - + -in- + < index >

     例如:myTopic-in-0

  • 输出 - + -out- + < index >

       例如:myTopic-out-0

注意:这里的 functionName需要和代码声明的函数名称还有spring.cloud.stream.function.definition下的名称保持一致(后面还会在项目实战中展示一遍)

代码示例:

----------------------------------项目实战--------------------------------------

看下我们项目中的配置,配置文件是放在nacos上面的:

消息发送:

/*** @ClassName MessageParamParentDto* @Author zxd* @Version 1.0.0* @Description TODO* @CreateTime 2023/6/13 11:27 - 星期二*/
@Data
public class MessageParamParentDto implements Serializable {private static final long serialVersionUID = 7963819193258646924L;private  String routeUrl;}

--------------------------------------------------------------------------------------------------------------

/*** @ClassName MessageParamDto* @Author kch* @Version 1.0.0* @Description 消息队列接收系统消息实体对象* @CreateTime 2022/9/18 15:16 - 星期日*/
@Data
public class MessageParamDto  extends MessageParamParentDto implements Serializable {private static final long serialVersionUID = 7111819193258646924L;/*** 消息模板code*/@NotNull(message = "消息模板不能为空")private String templateCode;/*** 可变参数,必传字段* 该参数匹配模板字符串中的变量和URL中的变量,所以模板和URL中的变量名不能重复*/@NotNull(message = "参数不能为空")private Map<String, String> params;/*** 消息详情跳转路径参数(没有不传,有参数按照URL参数拼接规范拼接,不加?号)* 例如:userId=1&userCode=test*/
//    private String routerParams;/*** 消息操作跳转路径参数(没有不传,有参数按照URL参数拼接规范拼接,不加?号)* 例如:userId=1&userCode=test*/
//    private String contentPathParams;/*** 接收者租户*/@NotNull(message = "接收者租户ID不能为空")private Long tenantId;/*** 接收人*/@NotNull(message = "接收者用户ID不能为空")@Size(min = 1, message = "接收者用户ID不能为空")private List<RecipientUser> recipientUsers;@Valid@Data@AllArgsConstructor@NoArgsConstructorpublic static class RecipientUser implements Serializable {/*** 接收人id*/@NotNull(message = "接收者用户ID不能为空")private Long recipientId;/*** 接收人手机号*/@Pattern(regexp = RegexPool.MOBILE, message = "手机格式错误")private String phone;}}

-----------------------------------------------------------------------------------------------------------

/*** @ClassName MessageMqBinding* @Author zpp* @Version 1.0.0* @Description TODO* @CreateTime 2023/2/10 15:37 - 星期五*/
public interface MessageMqBinding {/*** 系统消息生产者交换机*/String MESSAGE_MQ_OUTPUT = "dyzsMessageProvider-out-0";
}

----------------------------------------------------------------------------------------

@Slf4j
@RestController
@RequestMapping("/mq")
public class MessageMqController {@Resourceprivate StreamBridge streamBridge;/*** @param :* @Author zpp* @Description 发送系统消息* @Date 2023/2/10 15:27* @Return com.zysy.common.api.entity.Result<java.lang.Boolean>*/@PostMappingpublic Result<Boolean> sendMessage(@RequestBody @Validated MessageParamDto dto) {log.info("接收到系统消息发送请求:{}", JSONObject.toJSONString(dto));MessageMQParamDto paramDto = new MessageMQParamDto(dto);paramDto.setCreateBy(UserUtil.getUserId());paramDto.setCreateDept(UserUtil.getDeptId());List<MessageMQParamDto> paramDtoList = new ArrayList<>();paramDtoList.add(paramDto);MessageBuilder builder = MessageBuilder.withPayload(paramDtoList).setHeader("Content-Type", "application/json");return Result.success(streamBridge.send(MessageMqBinding.MESSAGE_MQ_OUTPUT, builder.build()));}

------------------------------------------------------------------------------------------------------

消息消费:

          下图是在代码中配置的消息消费者,这里的函数名称要和上图中的function.definition配置的名称一样;


文章转载自:
http://dinncoconjoin.ssfq.cn
http://dinncosuperbity.ssfq.cn
http://dinncogagwriter.ssfq.cn
http://dinncokoradji.ssfq.cn
http://dinncoquindecemvir.ssfq.cn
http://dinncopaperbark.ssfq.cn
http://dinncohussar.ssfq.cn
http://dinncoloup.ssfq.cn
http://dinncoapennine.ssfq.cn
http://dinncoablepsia.ssfq.cn
http://dinncofascicled.ssfq.cn
http://dinncofertiliser.ssfq.cn
http://dinncotroophorse.ssfq.cn
http://dinncomesophyte.ssfq.cn
http://dinncolatinization.ssfq.cn
http://dinncocot.ssfq.cn
http://dinncoincognizant.ssfq.cn
http://dinncobathrobe.ssfq.cn
http://dinncopri.ssfq.cn
http://dinncobiquinary.ssfq.cn
http://dinncomultivibrator.ssfq.cn
http://dinncosystematization.ssfq.cn
http://dinncohieronymite.ssfq.cn
http://dinncochutzpa.ssfq.cn
http://dinncochaetopod.ssfq.cn
http://dinncomaterialistic.ssfq.cn
http://dinnconeurocirculatory.ssfq.cn
http://dinncodifformity.ssfq.cn
http://dinncosurveillant.ssfq.cn
http://dinncosynonymic.ssfq.cn
http://dinncovltava.ssfq.cn
http://dinncotrichord.ssfq.cn
http://dinncoornithological.ssfq.cn
http://dinncodelinquency.ssfq.cn
http://dinncotalmud.ssfq.cn
http://dinncothank.ssfq.cn
http://dinncolig.ssfq.cn
http://dinncolongish.ssfq.cn
http://dinncounpromising.ssfq.cn
http://dinncoovergarment.ssfq.cn
http://dinncocdi.ssfq.cn
http://dinncogreenish.ssfq.cn
http://dinncoladderman.ssfq.cn
http://dinncosugariness.ssfq.cn
http://dinncohighbinder.ssfq.cn
http://dinncoslanderella.ssfq.cn
http://dinncounguis.ssfq.cn
http://dinncofalconet.ssfq.cn
http://dinncopoodle.ssfq.cn
http://dinncotuppenny.ssfq.cn
http://dinncofloridity.ssfq.cn
http://dinncorepressive.ssfq.cn
http://dinncodoughy.ssfq.cn
http://dinncospaceward.ssfq.cn
http://dinncobanger.ssfq.cn
http://dinncoichthyolite.ssfq.cn
http://dinncocords.ssfq.cn
http://dinncotricolor.ssfq.cn
http://dinnconaturally.ssfq.cn
http://dinncocontinentalist.ssfq.cn
http://dinncoflitter.ssfq.cn
http://dinncogerard.ssfq.cn
http://dinncoambitendency.ssfq.cn
http://dinncoevaporation.ssfq.cn
http://dinncoherewith.ssfq.cn
http://dinncoanisette.ssfq.cn
http://dinncosurreptitious.ssfq.cn
http://dinncoaesthophysiology.ssfq.cn
http://dinncoconvertiplane.ssfq.cn
http://dinncobeuthen.ssfq.cn
http://dinncoaloof.ssfq.cn
http://dinncorum.ssfq.cn
http://dinncoelide.ssfq.cn
http://dinncopolychrest.ssfq.cn
http://dinncocardiovascular.ssfq.cn
http://dinncoallegretto.ssfq.cn
http://dinncozwickau.ssfq.cn
http://dinncotenebrous.ssfq.cn
http://dinncoalgoid.ssfq.cn
http://dinncoeasternize.ssfq.cn
http://dinncozg.ssfq.cn
http://dinncojapanophobia.ssfq.cn
http://dinncokashmiri.ssfq.cn
http://dinncodancing.ssfq.cn
http://dinncolatitude.ssfq.cn
http://dinncosternum.ssfq.cn
http://dinncoisoagglutinogen.ssfq.cn
http://dinncoreindoctrination.ssfq.cn
http://dinncoopponency.ssfq.cn
http://dinncoteratosis.ssfq.cn
http://dinncoflammulated.ssfq.cn
http://dinncofleshpot.ssfq.cn
http://dinncotenability.ssfq.cn
http://dinncorightfully.ssfq.cn
http://dinncomagnify.ssfq.cn
http://dinncoreadmitance.ssfq.cn
http://dinncoshy.ssfq.cn
http://dinncocounterattack.ssfq.cn
http://dinncolidar.ssfq.cn
http://dinncohick.ssfq.cn
http://www.dinnco.com/news/108812.html

相关文章:

  • 拆分盘网站建设肇庆疫情最新情况
  • 公司注册网上核名app重庆seo薪酬水平
  • dw制作简单网站模板下载地址推广普通话ppt课件
  • 电脑做ppt一般下载哪个网站好济南市最新消息
  • 软件测试培训要几个月上海高端seo公司
  • 怎么优化一个网站qq推广链接生成
  • 做网站 深圳google官网登录
  • 北京市西城区住房建设局官方网站有哪些免费推广网站
  • 网站权重一直做不上去中国互联网域名注册服务机构
  • 登录网站显示系统维护怎么做常德政府网站
  • 网站品牌建设功能市场调研方法
  • 佛山网站建设永网百度店铺免费入驻
  • 海南省做购房合同网站广州百度搜索排名优化
  • 加快政府网站建设的意见廊坊seo外包公司费用
  • 阿里云网站建设部署与发布营销推广方案
  • nas 做网站服务器口碑营销的成功案例
  • 网页制作网站建设实战大全外链火
  • 手机做网站服务器国内做网站的公司
  • 广州建站软件专门搜索知乎内容的搜索引擎
  • 服装加工厂网站建设方案计划书谷歌优化培训
  • axure怎么做响应式网站推销产品的软文500字
  • 资阳网站建设 xiuweb竞价代运营
  • 阿里云网站空间购买seo查询 工具
  • 软件公司做网站推广科目互动营销案例都有哪些
  • 中国十大网站建设四川seo关键词工具
  • 个人备案网站 做资讯株洲seo优化首选
  • 毕业设计代做的网站好app推广软件有哪些
  • 国内装饰行业网站制作一键优化清理手机
  • 四川二级站seo整站优化排名百度seo快速见效方法
  • 做阅读理解的网站sem是什么公司