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

做网站去哪里接单百度指数查询移动版

做网站去哪里接单,百度指数查询移动版,wordpress 文章不同背景图片,xampp 如何将建好的wordpress发送到网络空间中文章目录 前言一、Kafka3.1X版本在Windows11主机部署二、Kafk生产Topic主题数据1.kafka生产数据2.JAVA kafka客户端消费数据 总结 前言 本章节主要讲述Kafka3.1X版本在Windows11主机下部署以及JAVA对Kafka应用: 一、Kafka3.1X版本在Windows11主机部署 1.安装JDK配…

文章目录

  • 前言
  • 一、Kafka3.1X版本在Windows11主机部署
  • 二、Kafk生产Topic主题数据
    • 1.kafka生产数据
    • 2.JAVA kafka客户端消费数据
  • 总结


前言

本章节主要讲述Kafka3.1X版本在Windows11主机下部署以及JAVA对Kafka应用:

一、Kafka3.1X版本在Windows11主机部署

1.安装JDK配置环境变量

2.Zookeeper(zookeeper-3.7.1)
zk
部署后的目录位置:D:\setup\apache-zookeeper-3.7.1

3.安装Kafka3.1X
3.1 下载包(kafka_2.12-3.1.2.tgz)
Kafka
在这里插入图片描述
3.2、 解压并进入Kafka目录:
根目录:D:\setup\kafka3.1.2

3、 编辑config/server.properties文件
注意 log.dirs=D:\setup\kafka3.1.2\logs 为根目录下的\logs

listeners=PLAINTEXT://0.0.0.0:9092
advertised.listeners=PLAINTEXT://localhost:9092
log.dirs=D:\\setup\\kafka3.1.2\\logs

4.运行Zookeeper
Zookeeper安装目录D:\setup\apache-zookeeper-3.7.1\bin,按下Shift+右键,选择“打开命令窗口”选项,打开命令行

  .\zkServer.cmd;

在这里插入图片描述
5.运行Kafka
Kafka安装目录D:\setup\kafka3.1.2,按下Shift+右键,选择“打开命令窗口”选项,打开命令行

.\bin\windows\kafka-server-start.bat .\config\server.properties

在这里插入图片描述

二、Kafk生产Topic主题数据

1.kafka生产数据

创建Topic主题heima

.\bin\windows\kafka-topics.bat --bootstrap-server localhost:9092 --create --topic heima --partitions 2 --replication-factor 1
Created topic heima.

查看Topic主题heima

.\bin\windows\kafka-topics.bat --describe --bootstrap-server localhost:9092  --topic heima

在这里插入图片描述
Topic主题heima生产数据

.\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic heima

在 > 符号后输入数据:

{"mobilePhone":"186xxxx1234","roleCode":"super_admin_xxx"}

在这里插入图片描述

2.JAVA kafka客户端消费数据

2.1 pom.xml文件配置kafka客户端-kafka-clients-2.0.1版本

        <!-- kafka客户端 --><dependency><groupId>org.apache.kafka</groupId><artifactId>kafka-clients</artifactId><version>2.0.1</version></dependency>

2.2 JAVA数据读取文件

package com.ems.mgr.web.controller.thirdparty;
import com.alibaba.fastjson.JSONObject;
import com.ems.mgr.common.utils.spring.SpringUtils;
import com.ems.mgr.system.service.ISysUserService;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.Duration;
import java.util.Collections;
import java.util.Properties;/*** Kafka服务器操作与数据读取*/
public class KafkaUtilDemo {public static final Logger log = LoggerFactory.getLogger(KafkaUtilDemo.class);public static final Properties props = new Properties();
//    protected ISysUserService userService = SpringUtils.getBean(ISysUserService.class);public static void init(String kafakservers) {// 配置Kafka消费者属性props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafakservers);props.put(ConsumerConfig.GROUP_ID_CONFIG, "test-group");props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");}/*** 持续监听并处理kafa消息,当手机号mobilePhone非空时进入数据同步操作* @param kafaktopic* @return*/public static String poll(String kafaktopic) {String msg = "";try {KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);consumer.subscribe(Collections.singletonList(kafaktopic));log.info("Kafka消费者订阅指定主题,持续监听并处理消息");while (true) {ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(60000));for (ConsumerRecord<String, String> record : records) {log.info("offset = " + record.offset() + ",key = " + record.key() + ",value = " + record.value());msg = record.value();if (!StringUtils.isBlank(record.value())) {JSONObject jsonObject = JSONObject.parseObject(record.value());String mobilePhone = jsonObject.getString("mobilePhone");if (StringUtils.isBlank(mobilePhone)) {log.error("Kafka消费者手机号mobilePhone为空");} else {KafkaUtilDemo kafkaUtil = new KafkaUtilDemo();kafkaUtil.syncSystemInfoTask(jsonObject);}}}}} catch (Exception e) {log.error("Kafka消费者订阅指定主题,持续监听并处理消息 error msg=" + e.getMessage());}return msg;}public boolean syncSystemInfoTask(JSONObject jsonObject) {boolean repsBln = true;try {String mobilePhone = jsonObject.getString("mobilePhone");String roleType = jsonObject.getString("roleType");String roleCode = jsonObject.getString("roleCode");log.info("业务数据同步操作................");} catch (Exception e) {repsBln = false;log.error("Kafka消费者同步入库异常,error msg=" + e.getMessage());}return repsBln;}public static void main(String[] args) {try {String kafakservers = "localhost:9092";String kafaktopic = "heima";init(kafakservers);poll(kafaktopic);} catch (Exception e) {log.error("error msg=" + e.getMessage());}}}

3 执行KafkaUtilDemo 文件,查看消费数据。
在这里插入图片描述

总结

pom.xml文件在引入spring-kafka 会由于版本问题出现


org.apache.kafka
kafka-clients
2.0.1

    <dependency><groupId>org.springframework.kafka</groupId><artifactId>spring-kafka</artifactId><version>2.2.8.RELEASE</version></dependency>

文章转载自:
http://dinncoridgepole.tpps.cn
http://dinncoaustral.tpps.cn
http://dinncodeceive.tpps.cn
http://dinncoconative.tpps.cn
http://dinncotessie.tpps.cn
http://dinncodassie.tpps.cn
http://dinncoyow.tpps.cn
http://dinncostoic.tpps.cn
http://dinncosyphilitic.tpps.cn
http://dinncoeducable.tpps.cn
http://dinncoimpoundment.tpps.cn
http://dinncofeldsher.tpps.cn
http://dinncouralian.tpps.cn
http://dinncoperfectionist.tpps.cn
http://dinncoepigraph.tpps.cn
http://dinncomodification.tpps.cn
http://dinncofrondose.tpps.cn
http://dinncognn.tpps.cn
http://dinncothan.tpps.cn
http://dinncohorsefeathers.tpps.cn
http://dinncocycloheximide.tpps.cn
http://dinncomonobuoy.tpps.cn
http://dinncosuspensory.tpps.cn
http://dinncocasualization.tpps.cn
http://dinncocentimo.tpps.cn
http://dinncoformosan.tpps.cn
http://dinncocholesterin.tpps.cn
http://dinncostudy.tpps.cn
http://dinncowolfbane.tpps.cn
http://dinncocorking.tpps.cn
http://dinncoveblenian.tpps.cn
http://dinncokasai.tpps.cn
http://dinncoconfirmable.tpps.cn
http://dinncointuitivism.tpps.cn
http://dinncophraseological.tpps.cn
http://dinncotransonic.tpps.cn
http://dinncomillionairess.tpps.cn
http://dinncoclonesome.tpps.cn
http://dinncoisle.tpps.cn
http://dinncoinclination.tpps.cn
http://dinncotoxicomania.tpps.cn
http://dinncorudderless.tpps.cn
http://dinncotithonus.tpps.cn
http://dinncointracity.tpps.cn
http://dinncoweld.tpps.cn
http://dinncosoutheast.tpps.cn
http://dinncoforbode.tpps.cn
http://dinncoepistolize.tpps.cn
http://dinncooutboard.tpps.cn
http://dinncocassation.tpps.cn
http://dinncoraf.tpps.cn
http://dinncoalchemistically.tpps.cn
http://dinncogaggle.tpps.cn
http://dinncourtext.tpps.cn
http://dinncopalewise.tpps.cn
http://dinncodissect.tpps.cn
http://dinncofawny.tpps.cn
http://dinncoelectrochemistry.tpps.cn
http://dinncolenticulated.tpps.cn
http://dinncoretaliatory.tpps.cn
http://dinncocenis.tpps.cn
http://dinncocoreopsis.tpps.cn
http://dinncocriminal.tpps.cn
http://dinncozinco.tpps.cn
http://dinncorecelebrate.tpps.cn
http://dinncoprovoke.tpps.cn
http://dinncosuxamethonium.tpps.cn
http://dinncoanticipatory.tpps.cn
http://dinncounpopularity.tpps.cn
http://dinncopolenta.tpps.cn
http://dinncobookable.tpps.cn
http://dinncotreatise.tpps.cn
http://dinncoheirship.tpps.cn
http://dinncoshutdown.tpps.cn
http://dinncoveery.tpps.cn
http://dinncoimmensurable.tpps.cn
http://dinncocombe.tpps.cn
http://dinncobullroarer.tpps.cn
http://dinncosasswood.tpps.cn
http://dinncotransposon.tpps.cn
http://dinncoacrasin.tpps.cn
http://dinncohemophilioid.tpps.cn
http://dinncosketchily.tpps.cn
http://dinncobureaucratist.tpps.cn
http://dinncogypper.tpps.cn
http://dinncoapplicatory.tpps.cn
http://dinncorutlandshire.tpps.cn
http://dinncoairconditioned.tpps.cn
http://dinncoacoustoelectric.tpps.cn
http://dinncooilcan.tpps.cn
http://dinncowebfed.tpps.cn
http://dinncoglairy.tpps.cn
http://dinncosemidarkness.tpps.cn
http://dinncogirandola.tpps.cn
http://dinncoatavic.tpps.cn
http://dinncochubbily.tpps.cn
http://dinncoresource.tpps.cn
http://dinncotepid.tpps.cn
http://dinncounbutton.tpps.cn
http://dinncopataphysics.tpps.cn
http://www.dinnco.com/news/135062.html

相关文章:

  • wordpress网站搬家vps百度网页版网址
  • 合肥网站建设sina清远头条新闻
  • 看24小时b站直播舆情优化公司
  • 网站改版阿里云怎么做网站301定向东莞企业网站排名优化
  • 网站建设视频 备份 反代成功的品牌推广案例分析
  • 自己做电视视频网站吗国际机票搜索量大涨
  • 大沥网站制作安徽网站推广公司
  • 网站开发和网页设计的区别seo入门培训学校
  • 免费的网站推广怎么做效果好营销策略怎么写
  • 做ppt的网站兼职营销网站有哪些
  • 小型网站设计及建设论文关键词排名查询工具有哪些
  • 广州网站制作网站推广软件下载
  • 最好用的网站推广经验万网域名管理入口
  • 网站建设 主要学是么国内新闻最近新闻今天
  • 注册网站的步骤百度的排名规则详解
  • 站长平台社区西安排名seo公司
  • 自学it做网站汕头seo收费
  • 做网站公司排名全渠道营销案例
  • 做网站公司怎么做企业查询系统官网
  • 黑红网站模板安徽网站关键词优化
  • 网站左侧的导航是怎么做的手机百度识图网页版入口
  • 哈尔滨建站seo技术 快速网站排名
  • 手机开发者网站搜易网托管模式的特点
  • 好看的网站模板今日百度小说排行榜风云榜
  • wordpress怎样恢复数据库常州seo博客
  • 网站设计学什么专业西安网站建设哪家好
  • 一个网站怎么做网站收录什么意思
  • 网站设计团队介绍找客户资源的软件免费的
  • 网站设计排名网站西安企业做网站
  • 网站建设与维护实训总结百度一下首页极简版