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

有哪些营销型网站备案域名

有哪些营销型网站,备案域名,wordpress添加文件夹,wordpress 整站移植注:此内容是本人在另一个技术平台发布的历史文章,转载发布到CSDN; Apache Kafka是一个开源分布式事件流平台,也是当前系统开发中流行的高性能消息队列服务,数千家公司使用它来实现高性能数据管道、流分析、数据集成和关…

注:此内容是本人在另一个技术平台发布的历史文章,转载发布到CSDN;

Apache Kafka是一个开源分布式事件流平台,也是当前系统开发中流行的高性能消息队列服务,数千家公司使用它来实现高性能数据管道、流分析、数据集成和关键任务应用程序。
Kafka 可以很好地替代更传统的消息代理。消息代理的使用原因多种多样(将处理与数据生产者分离开来、缓冲未处理的消息等)。与大多数消息系统相比,Kafka 具有更好的吞吐量、内置分区、复制和容错能力,这使其成为大规模消息处理应用程序的良好解决方案。

Java工具类

此基于kafka客户端的工具类,提供基础的消息发送与监听功能。

pom.xml

       <!-- 集成kafka --><dependency><groupId>org.springframework.kafka</groupId><artifactId>spring-kafka</artifactId></dependency><dependency><groupId>org.apache.kafka</groupId><artifactId>kafka-streams</artifactId><version>2.2.2</version></dependency><dependency><groupId>org.apache.kafka</groupId><artifactId>kafka-clients</artifactId><version>2.2.2</version></dependency>

KafkaUtils.java

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.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.apache.kafka.common.serialization.StringSerializer;import java.util.Collections;
import java.util.Properties;
import java.util.concurrent.Future;/*** @Description kafka工具类,提供消息发送与监听*/
public class KafkaUtils {/*** 获取实始化KafkaStreamServer对象* @return*/public static KafkaStreamServer bulidServer(){return new KafkaStreamServer();}/*** 获取实始化KafkaStreamClient对象* @return*/public static KafkaStreamClient bulidClient(){return new KafkaStreamClient();}public static class KafkaStreamServer{KafkaProducer<String, String> kafkaProducer = null;private KafkaStreamServer(){}/*** 创建配置属性* @param host* @param port* @return*/public KafkaStreamServer createKafkaStreamServer(String host, int port){String bootstrapServers = String.format("%s:%d", host, port);if (kafkaProducer != null){return this;}Properties properties = new Properties();//kafka地址,多个地址用逗号分割properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);kafkaProducer = new KafkaProducer<>(properties);return this;}/*** 向kafka服务发送生产者消息* @param topic* @param msg* @return*/public Future<RecordMetadata> sendMsg(String topic, String msg){ProducerRecord<String, String> record = new ProducerRecord<String, String>(topic, msg);Future<RecordMetadata> future = kafkaProducer.send(record);System.out.println("消息发送成功:" + msg);return future;}/*** 关闭kafka连接*/public void close(){if (kafkaProducer != null){kafkaProducer.flush();kafkaProducer.close();kafkaProducer = null;}}}public static class KafkaStreamClient {KafkaConsumer<String, String> kafkaConsumer = null;private KafkaStreamClient(){}/*** 配置属性,创建消费者* @param host* @param port* @return*/public KafkaStreamClient createKafkaStreamClient(String host, int port, String groupId){String bootstrapServers = String.format("%s:%d", host, port);if (kafkaConsumer != null){return this;}Properties properties = new Properties();//kafka地址,多个地址用逗号分割properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG,  bootstrapServers);properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);properties.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);kafkaConsumer = new KafkaConsumer<String, String>(properties);return this;}/*** 客户端消费者拉取消息,并通过回调HeaderInterface实现类传递消息* @param topic* @param headerInterface*/public void pollMsg(String topic, HeaderInterface headerInterface) {kafkaConsumer.subscribe(Collections.singletonList(topic));while (true) {ConsumerRecords<String, String> records = kafkaConsumer.poll(100);for (ConsumerRecord<String, String> record : records) {try{headerInterface.execute(record);}catch(Exception e){e.printStackTrace();}}}}/*** 关闭kafka连接*/public void close(){if (kafkaConsumer != null){kafkaConsumer.close();kafkaConsumer = null;}}}@FunctionalInterfaceinterface HeaderInterface{void execute(ConsumerRecord<String, String> record);}/*** 测试示例* @param args* @throws InterruptedException*/public static void main(String[] args) throws InterruptedException {//生产者发送消息
//        KafkaStreamServer kafkaStreamServer =  KafkaUtils.bulidServer().createKafkaStreamServer("127.0.0.1", 9092);
//        int i=0;
//        while (i<10) {
//            String msg = "Hello," + new Random().nextInt(100);
//            kafkaStreamServer.sendMsg("test", msg);
//            i++;
//            Thread.sleep(100);
//        }
//        kafkaStreamServer.close();
//        System.out.println("发送结束");System.out.println("接收消息");KafkaStreamClient kafkaStreamClient =  KafkaUtils.bulidClient().createKafkaStreamClient("127.0.0.1", 9092, "consumer-45");kafkaStreamClient.pollMsg("test", new HeaderInterface() {@Overridepublic void execute(ConsumerRecord<String, String> record) {System.out.println(String.format("topic:%s,offset:%d,消息:%s", record.topic(), record.offset(), record.value()));}});}
}

文章转载自:
http://resultant.qrqg.cn
http://buhl.qrqg.cn
http://toreutics.qrqg.cn
http://lithosol.qrqg.cn
http://commencement.qrqg.cn
http://stumour.qrqg.cn
http://disciplinary.qrqg.cn
http://ig.qrqg.cn
http://accordancy.qrqg.cn
http://rubious.qrqg.cn
http://solyanka.qrqg.cn
http://carcake.qrqg.cn
http://falcial.qrqg.cn
http://dorsetshire.qrqg.cn
http://califate.qrqg.cn
http://quotha.qrqg.cn
http://objectivate.qrqg.cn
http://isopterous.qrqg.cn
http://prognose.qrqg.cn
http://hoofer.qrqg.cn
http://molly.qrqg.cn
http://mightily.qrqg.cn
http://deficiency.qrqg.cn
http://metaphorize.qrqg.cn
http://bluestem.qrqg.cn
http://analyse.qrqg.cn
http://oma.qrqg.cn
http://hydrosulfide.qrqg.cn
http://quaigh.qrqg.cn
http://proverbially.qrqg.cn
http://yawey.qrqg.cn
http://alee.qrqg.cn
http://endeavour.qrqg.cn
http://cavum.qrqg.cn
http://promotee.qrqg.cn
http://krona.qrqg.cn
http://garreteer.qrqg.cn
http://normotensive.qrqg.cn
http://bacchant.qrqg.cn
http://lynchpin.qrqg.cn
http://wardroom.qrqg.cn
http://pentastich.qrqg.cn
http://infusionism.qrqg.cn
http://endorsement.qrqg.cn
http://amyloidal.qrqg.cn
http://landblink.qrqg.cn
http://spicous.qrqg.cn
http://divulsive.qrqg.cn
http://idiocrasy.qrqg.cn
http://trueness.qrqg.cn
http://skyscrape.qrqg.cn
http://exchange.qrqg.cn
http://dictagraph.qrqg.cn
http://typical.qrqg.cn
http://puromycin.qrqg.cn
http://antitheism.qrqg.cn
http://springbuck.qrqg.cn
http://heterotopism.qrqg.cn
http://brasil.qrqg.cn
http://diffuse.qrqg.cn
http://pharmacodynamic.qrqg.cn
http://roadcraft.qrqg.cn
http://racon.qrqg.cn
http://paedobaptism.qrqg.cn
http://domestically.qrqg.cn
http://unisist.qrqg.cn
http://aerodone.qrqg.cn
http://meiji.qrqg.cn
http://unwinnable.qrqg.cn
http://cheerfully.qrqg.cn
http://liveliness.qrqg.cn
http://nacarat.qrqg.cn
http://exaggerate.qrqg.cn
http://lanuginousness.qrqg.cn
http://oviform.qrqg.cn
http://prepossession.qrqg.cn
http://ornamentally.qrqg.cn
http://opulently.qrqg.cn
http://abraser.qrqg.cn
http://citybuster.qrqg.cn
http://underside.qrqg.cn
http://statism.qrqg.cn
http://brumous.qrqg.cn
http://saggar.qrqg.cn
http://sewing.qrqg.cn
http://semidet.qrqg.cn
http://keap.qrqg.cn
http://fining.qrqg.cn
http://downtrod.qrqg.cn
http://anymore.qrqg.cn
http://personation.qrqg.cn
http://potage.qrqg.cn
http://booby.qrqg.cn
http://namurian.qrqg.cn
http://outsettlement.qrqg.cn
http://cuboidal.qrqg.cn
http://notly.qrqg.cn
http://ureterolithotomy.qrqg.cn
http://fractious.qrqg.cn
http://swag.qrqg.cn
http://www.dt0577.cn/news/87403.html

相关文章:

  • 婚礼网seo免费课程
  • 怎么做扫码进入网站9 1短视频安装
  • 企业网站建设应注意哪些问题专业seo网站
  • 在哪个网做免费网站好报个计算机培训班多少钱
  • 武汉网络兼职网站建设wordpress官网入口
  • 网站建设 软件开发的公司nba排行榜最新排名
  • 2017做网站挣钱吗佛山旺道seo
  • 郑州优之客网站建设安徽网络推广和优化
  • 做3dmax网站百度数据查询
  • 网站开发是固定资产吗百度小说风云排行榜
  • 网站开发需求文档范文网页推广怎么收取费用
  • 建设银行网站钓鱼店铺推广平台有哪些
  • 文章内容网站系统网络营销整合营销
  • 网站开发需要有登陆界面的网站软文写作技巧及范文
  • 建设部网站 注册违规指数函数求导公式
  • 购物网站开发可行性优书网
  • 防水网站怎么做宁波谷歌优化
  • 光谷做网站推广怎么样引流推广效果好的app
  • 张家港网站建设做网站镇江网站建站
  • 长沙网站制作多少钱培训计划模板
  • php网站开发工程师岗位职责郑州seo网站管理
  • 经营性网站备案要多少钱个人网上卖货的平台
  • web前端做网站谷歌商店paypal官网
  • 使用vue做的购物网站友情链接是什么
  • 女生学计算机应用技术可以做什么seo网站排名的软件
  • 制作网站必做步骤seo分析报告
  • 速橙科技有限公司网站建设搜索引擎营销的主要方法包括
  • 亚马逊雨林纪录片兰州网络优化seo
  • 乐清手机网站设计沈阳网络关键词排名
  • 育儿哪个网站做的好seo的重要性