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

网站上的流动图片怎么做的电影网站模板源代码

网站上的流动图片怎么做的,电影网站模板源代码,iis做本地视频网站,英文网站模板cms目录 概述使用准备工作引入依赖创建Topic代码应用启动消息接收再扩展一个 结束 概述 github 文档地址 rocket mq example RocketMQ 版本为 5.1.4 使用 准备工作 阅读此文需要事先准备 RocketMQ ,如有疑问,请移步 RocketMQ 服务搭建 引入依赖 此处…

目录

  • 概述
  • 使用
    • 准备工作
    • 引入依赖
    • 创建Topic
    • 代码
    • 应用启动
    • 消息接收
    • 再扩展一个
  • 结束

概述

github 文档地址
rocket mq example

RocketMQ 版本为 5.1.4

使用

准备工作

阅读此文需要事先准备 RocketMQ ,如有疑问,请移步 RocketMQ 服务搭建

引入依赖

此处,多依赖了一些依赖。

<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
</dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency>

创建Topic

sh bin/mqadmin updateTopic -n localhost:9876 -c DefaultCluster -t test-topic

在这里插入图片描述

代码

配置 Input 和 Output 的 Binding 信息并配合 @EnableBinding 注解使其生效

@EnableBinding({ Source.class, Sink.class })
@EnableDiscoveryClient
@SpringBootApplication
public class MqApplication {public static void main(String[] args) {SpringApplication.run(MqApplication.class);}
}

配置 Binding 信息:

# 配置rocketmq的nameserver地址
spring.cloud.stream.rocketmq.binder.name-server=10.xx.xx.143:9876
# 定义name为output的binding
spring.cloud.stream.bindings.output.destination=test-topic
spring.cloud.stream.bindings.output.content-type=application/json
# 定义name为input的binding
spring.cloud.stream.bindings.input.destination=test-topic
spring.cloud.stream.bindings.input.content-type=application/json
spring.cloud.stream.bindings.input.group=test-group

发送消息代码:

public class RocketMQProducer {public static void main(String[] args) throws MQClientException, MQBrokerException, RemotingException, InterruptedException {DefaultMQProducer producer = new DefaultMQProducer("producer_group");producer.setNamesrvAddr("10.xx.xx.143:9876");producer.start();Message msg = new Message("test-topic", "tagStr", "message from rocketmq producer".getBytes());producer.send(msg);}
}

应用启动

1.增加配置,在应用的 /src/main/resources/application.properties 中添加基本配置信息

spring:application:name: mq
server:port: 9700

2.启动应用,支持 IDE 直接启动和编译打包后启动。

  • IDE 直接启动:找到主类 RocketMQApplication,执行 main 方法启动应用。
  • 打包编译后启动:首先执行 mvn clean package 将工程编译打包,然后执行 java -jar rocketmq-example.jar 启动应用。

消息接收

使用 name 为 output 对应的 binding 发送消息到 test-topic 这个 topic。

@Service
public class ReceiveService {@StreamListener("input1")public void receiveInput1(String receiveMsg) {System.out.println("input1 receive: " + receiveMsg);}
}

在这里插入图片描述

再扩展一个

一个服务中要使用多个 Topic ,这种情况如何解决?下面给出解决方案。

public interface Input2Sink extends Sink {String INPUT2 = "input2";@Input(Input2Sink.INPUT2)SubscribableChannel input2();
}
public interface Output2Source extends Source {String OUTPUT2 = "output2";@Output(Output2Source.OUTPUT2)MessageChannel output2();
}
@Service
public class ReceiveService {@StreamListener("input")public void receiveInput1(String receiveMsg) {System.out.println("input receive: " + receiveMsg);}@StreamListener("input2")public void receiveInput2(String receiveMsg) {System.out.println("input2 receive: " + receiveMsg);}
}
@EnableBinding(value = {Source.class, Sink.class, Output2Source.class, Input2Sink.class})
@EnableDiscoveryClient
@SpringBootApplication
public class MqApplication {public static void main(String[] args) {SpringApplication.run(MqApplication.class);}
}

结果如下:
在这里插入图片描述

结束

spring cloud alibaba RocketMQ 最佳实践 ,至此就结束了,如有疑问,欢迎评论区留言。

http://www.yayakq.cn/news/746719/

相关文章:

  • 织梦网站为什么容易被注入西部数码网站打不开
  • 阜阳做网站的公司标记位置的地图微信小程序开发教程
  • 福建省城乡和住房建设厅网站2017设计工作室做网站
  • 建网站 域名wordpress 清空 demo
  • 怎么增加网站收录郑州网页设计公司有哪些
  • 安丘网站建设制作做微商加入什么移动电商网站
  • 企业手机端网站模板二手车网站建站
  • 做代码的网站c2c模式的典型代表
  • 网站权重排行榜设计制作小车二教案
  • 建设英文外贸网站如何在卖家淘宝网站做产品链接
  • 网易做网站吗郑州哪家网站建设好
  • lol做直播网站南京尘帆网站建设
  • 个人网站代码模板学做ppt的网站
  • 做的网站在百度上搜不出来wordpress相关推荐
  • 套餐型网站建设合同东莞网络营销推广渠道
  • 随州网站建设便宜个人网站怎么做支付宝接口
  • 任意做别的公司网站销售产品违法吗天津企悦在线网站建设
  • 网站开发招标任务书医院管理系统网站开发
  • 做原创品牌服饰的网站itmc平台seo优化关键词个数
  • 网站开发实训总结致谢iis与wordpress
  • 劳力士手表网站营销型公司网站
  • 定制网站系统大连市网站建设
  • 北京网站建设公司拟网页制作有什么软件
  • 南京建设网站费用网站建设的财务计划
  • 做网站的可以黑客户的网站吗慈溪网站建设哪家好
  • 2018年期刊网站建设调查石家庄网站外包
  • 网站前期设计五通桥移动网站建设
  • 宣传推广渠道有哪些seo文章优化方法
  • 太原seo排名优化软件绍兴网站建设seo
  • 旅游营销型网站上海暂停娱乐场所营业通知