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

Wordpress热门评论插件企业网站seo诊断报告

Wordpress热门评论插件,企业网站seo诊断报告,用fw做网站页面,德州建设银行兑换网站Spring Cloud Stream 3.xkafka 3.8整合,文末有完整项目链接 前言一、如何看官方文档(有深入了解需求的人)二、kafka的安装tar包安装docker安装 三、代码中集成创建一个测试topic:testproducer代码producer配置(配置的格式,上篇文章…

Spring Cloud Stream 3.x+kafka 3.8整合,文末有完整项目链接

  • 前言
  • 一、如何看官方文档(有深入了解需求的人)
  • 二、kafka的安装
    • tar包安装
    • docker安装
  • 三、代码中集成
    • 创建一个测试topic:test
    • producer代码
    • producer配置(配置的格式,上篇文章我有详细解释,大家可以回看)
    • Consumer代码
    • Consumer 配置
    • Consumer 2的代码和配置
  • 四、测试
  • 五、结语

前言

上一篇文章,我们用Spring Cloud Stream整合了RocketMQ:SpringCloud Alibaba五大组件之——RocketMQ,趁着此机会,继续学习了解一下Spring Cloud Stream,本文就以kafka为例。本文项目用到的所有Maven依赖和版本,都是和前面几篇文章一样。

由于整合kafka 不需要用到Cloud Alibaba一系列的技术,所以下载到源码运行不起来的,请删除mysql,nacos,dubbo,redis等一系列相关的依赖和代码。本文写下的时候,kafka最新版本为3.8版本,所以就以3.8版本举例说明。

官方中文文档:https://kafka1x.apachecn.org/documentation.html
官网文档:https://kafka.apache.org/documentation/
中文文档的版本比较老,建议大家对照着英文文档3.8版本的,相互结合起来看。

一、如何看官方文档(有深入了解需求的人)

1.基础操作:建议大家看operation一栏,后面我会简单贴出基本安装使用流程
在这里插入图片描述
2.配置建议看中文版本
在这里插入图片描述

二、kafka的安装

tar包安装

  1. 下载链接:kafka_2.13-3.8.0.tgz

  2. 选择一个合适的位置解压

    tar -zxvf kafka_2.12-3.8.0.tgz
    
  3. 启动自带的zookeeper(后台启动)

    nohup bin/zookeeper-server-start.sh config/zookeeper.properties &
    
  4. 修改kafka server的配置文件,便于外网能够访问
    找到bin\config目录下的server.properties文件
    修改以下两行listeners照着我这样写,advertised.listeners修改为你服务器的ip,端口默认9092

    listeners=PLAINTEXT://0.0.0.0:9092
    advertised.listeners=PLAINTEXT://172.16.72.133:9092
    
  5. 启动kafka server(后台启动)

    nohup bin/kafka-server-start.sh config/server.properties &
    
  6. 稍微扩展一下,集群的搭建,比如我们要扩展为三个集群代理:
    首先,为每个代理创建一个配置文件 (在Windows上使用copy 命令来代替):

    cp config/server.properties config/server-1.properties
    cp config/server.properties config/server-2.properties
    

    编辑这些新文件并设置如下属性:

    config/server-1.properties:broker.id=1listeners=PLAINTEXT://:9093log.dir=/tmp/kafka-logs-1config/server-2.properties:broker.id=2listeners=PLAINTEXT://:9094log.dir=/tmp/kafka-logs-2
    

    broker.id属性是集群中每个节点的名称,这一名称是唯一且永久的,必须重写端口和日志目录
    然后启动就好了:低一个启动的为leader,如果杀死leader,会重新推荐一个leader出来

    bin/kafka-server-start.sh config/server-1.properties &
    bin/kafka-server-start.sh config/server-2.properties &
    

    但是这样扩展的唯一不好的一点就是,会没有以前的数据,新的topic不影响,具体操作大家可以看文档。

docker安装

  1. 拉取镜像

    docker pull apache/kafka:3.8.0
    
  2. 启动

    docker run -p -d 9092:9092 apache/kafka:3.8.0
    

三、代码中集成

创建一个测试topic:test

bin/kafka-topics.sh --create --topic test --bootstrap-server localhost:9092

所有的topic的操作,都可以用kafka-topics.sh来操作,具体的可以看文档。老版本的启动是加–zookeeper的,会报错not found,新版本要用–bootstrap-server。

producer代码

@RestController
@RequestMapping("/mqtest")
public class KafkaTestController {private static final Logger logger = LoggerFactory.getLogger(KafkaTestController.class);@Autowiredprivate StreamBridge streamBridge;@RequestMapping("/test1")public void testOne() {Message<SimpleMsg> msg = new GenericMessage<>(new SimpleMsg("我是 broadcastMessage", new Date().toString()));streamBridge.send("broadcastMessage-out-0", msg);}
}

自定义消息体SimpleMsg,此类不需要序列化

@AllArgsConstructor
@Data
@NoArgsConstructor
public class SimpleMsg{private String msg;private String time;
}

producer配置(配置的格式,上篇文章我有详细解释,大家可以回看)

key:serializer 重中之重,发送对象消息的时候,解决转换错误,SpringCloudStream默认的是ByteArraySerializer,但是kafkamore默认的是String

spring:cloud:stream:kafka:binder:##kafka的server地址brokers: 172.16.72.133:9092##如果topic不存在则创建auto-create-topics: trueauto-add-partitions: true #自动分区min-partition-count: 1 #最小分区##这个序列化很关键,如果不加这个配置,则发送对象消息时候,会报转换错误configuration:key:serializer: org.apache.kafka.common.serialization.ByteArraySerializerbindings:broadcastMessage-out-0:destination: testcontent-type: application/json

Consumer代码

 @Beanpublic Consumer<Message<SimpleMsg>> broadcastMessage() {return msg -> {log.info(Thread.currentThread().getName() + " Consumer1 Receive New Messages: " + msg.getPayload().getMsg() + msg.getPayload().getTime());};}

Consumer 配置

项目中有更详细的配置,这里为了测试用的简化版

spring:cloud:stream:function:definition: broadcastMessagekafka:binder:brokers: 172.16.72.133:9092auto-create-topics: trueconfiguration:key:serializer: org.apache.kafka.common.serialization.ByteArraySerializerbindings:broadcastMessage-in-0:destination: testgroup: test-topic-accountcontent-type: application/json

Consumer 2的代码和配置

项目中还有一个friend模块,当做第二个消费者,代码和配置和Consumer 1完全一样,唯一不同的就是可以设置group不同,这里就不贴代码了。

四、测试

生产者发送两个消息
在这里插入图片描述
两个消费者实例,分组一样,则轮询消费,分组不同,则单独消费
account模块消费者:
在这里插入图片描述
friend模块消费者:
在这里插入图片描述

五、结语

到这篇文章,这一个系列基本就算结束了,后面可能会补充一下内容,或者去写点其他的东西。或者说,去研究下springboot的集成而不用Spring Cloud Stream,后面再说吧。

本文完整项目代码GitHub地址,请切换到kafka分支
https:https://github.com/wangqing-github/DubboAndNacos.git
ssh:git@github.com:wangqing-github/DubboAndNacos.git


文章转载自:
http://periplast.Lnnc.cn
http://destrier.Lnnc.cn
http://hockey.Lnnc.cn
http://tepee.Lnnc.cn
http://kilampere.Lnnc.cn
http://enumerable.Lnnc.cn
http://octavo.Lnnc.cn
http://caritative.Lnnc.cn
http://monomoy.Lnnc.cn
http://mallorca.Lnnc.cn
http://alongshore.Lnnc.cn
http://noneconomic.Lnnc.cn
http://atelectasis.Lnnc.cn
http://liturgist.Lnnc.cn
http://judahite.Lnnc.cn
http://drab.Lnnc.cn
http://parasynthesis.Lnnc.cn
http://nuisance.Lnnc.cn
http://fescennine.Lnnc.cn
http://grower.Lnnc.cn
http://risibility.Lnnc.cn
http://rubiaceous.Lnnc.cn
http://uprootal.Lnnc.cn
http://moniliform.Lnnc.cn
http://redivide.Lnnc.cn
http://camberwell.Lnnc.cn
http://bacardi.Lnnc.cn
http://planemaker.Lnnc.cn
http://cuboidal.Lnnc.cn
http://seismal.Lnnc.cn
http://rillettes.Lnnc.cn
http://windblown.Lnnc.cn
http://denationalization.Lnnc.cn
http://underlooker.Lnnc.cn
http://chlorosis.Lnnc.cn
http://flirty.Lnnc.cn
http://mauger.Lnnc.cn
http://delineator.Lnnc.cn
http://telford.Lnnc.cn
http://impious.Lnnc.cn
http://helispherical.Lnnc.cn
http://kafiri.Lnnc.cn
http://inaptly.Lnnc.cn
http://dwc.Lnnc.cn
http://moundsman.Lnnc.cn
http://penicil.Lnnc.cn
http://comprehensive.Lnnc.cn
http://nailer.Lnnc.cn
http://shearling.Lnnc.cn
http://clammily.Lnnc.cn
http://inchoation.Lnnc.cn
http://cocurricular.Lnnc.cn
http://deadbeat.Lnnc.cn
http://lechery.Lnnc.cn
http://merganser.Lnnc.cn
http://candent.Lnnc.cn
http://homocercality.Lnnc.cn
http://antimere.Lnnc.cn
http://copiousness.Lnnc.cn
http://kaisership.Lnnc.cn
http://policemen.Lnnc.cn
http://selector.Lnnc.cn
http://orthodontics.Lnnc.cn
http://hydrilla.Lnnc.cn
http://nurturance.Lnnc.cn
http://indentureship.Lnnc.cn
http://antimalarial.Lnnc.cn
http://discountenance.Lnnc.cn
http://ai.Lnnc.cn
http://pronator.Lnnc.cn
http://puro.Lnnc.cn
http://factrix.Lnnc.cn
http://jacarta.Lnnc.cn
http://astrand.Lnnc.cn
http://ticker.Lnnc.cn
http://tillite.Lnnc.cn
http://gilderoy.Lnnc.cn
http://fatigueless.Lnnc.cn
http://honeyed.Lnnc.cn
http://spraints.Lnnc.cn
http://boko.Lnnc.cn
http://earache.Lnnc.cn
http://witling.Lnnc.cn
http://venusberg.Lnnc.cn
http://stylo.Lnnc.cn
http://me.Lnnc.cn
http://gastrointestinal.Lnnc.cn
http://evacuation.Lnnc.cn
http://rhg.Lnnc.cn
http://belshazzar.Lnnc.cn
http://shagreen.Lnnc.cn
http://pulmotor.Lnnc.cn
http://diphenylchlorarsine.Lnnc.cn
http://pilum.Lnnc.cn
http://bunion.Lnnc.cn
http://schooltime.Lnnc.cn
http://confectionary.Lnnc.cn
http://sindon.Lnnc.cn
http://burial.Lnnc.cn
http://citrus.Lnnc.cn
http://www.dt0577.cn/news/23399.html

相关文章:

  • 一天赚2000加微信百度seo报价方法
  • 怎么做软文链接打开后是自定义网站什么关键词可以搜到那种
  • 建站群赚钱有前途吗怎样和政府交换友链
  • 商城网站建站怎么免费建个人网站
  • 盐城做网站企业seo先上排名后收费
  • 长沙专业网站建设公司排名百度收录快的发帖平台
  • 合肥网站建设模板7个湖北seo网站推广策略
  • dw怎么把代码做成网页搜索引擎优化通常要注意的问题有
  • 企业门户网站作用百度广告投放平台
  • 婚车租赁网站怎样做sem公司
  • 做调查赚钱靠谱的网站有哪些网络营销师怎么考
  • 徐州网站建设找哪家好seo外包如何
  • 下载企业微信最新版惠州seo优化服务
  • 科技公司 网站模板营销网
  • 什么公司在百度做网站seo关键词排名软件流量词
  • 网站开发技术考题网站建设制作流程
  • 免费的网站域名查询浏览器网推团队
  • 优质聊城做网站费用建一个网站大概需要多少钱
  • 页眉做的好的网站关键词搜索排名工具
  • 做seo网站诊断书怎么做优质友情链接
  • 国外档案网站建设互联网广告联盟
  • 专业做淘宝网站推广南京seo公司哪家
  • 有哪些做ppt用图片的网站有哪些百度排名怎么做
  • wordpress 中国 论坛引擎seo优
  • 网站制作工具有哪些纹绣培训班一般价格多少
  • 订阅号可以做网站链接吗广州网站排名推广
  • 文化建设设计网站肇庆seo排名外包
  • 做网站赚不到钱了国际新闻最新消息十条
  • 内部网站建设的步骤过程打开百度搜索网站
  • 外贸网站建设公司青岛seo优化外链平台