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

北京怎样做网站推广wordpress后台如何登录

北京怎样做网站推广,wordpress后台如何登录,电脑传奇游戏哪个好玩,网站建设对企业很重要需求 我们需要通过Spring Kafka库#xff0c;将消息推送给Kafka的topic中。这里假设Kafka的集群和用户我们都有了。这里Kafka认证采取SASL_PLAINTEXT方式接入#xff0c;SASL 采用 SCRAM-SHA-256 方式加解密。 pom.xml dependencygroupIdorg.springframew…需求 我们需要通过Spring Kafka库将消息推送给Kafka的topic中。这里假设Kafka的集群和用户我们都有了。这里Kafka认证采取SASL_PLAINTEXT方式接入SASL 采用 SCRAM-SHA-256 方式加解密。 pom.xml dependencygroupIdorg.springframework.kafka/groupIdartifactIdspring-kafka/artifactId /dependency我这里不需要写版本号应为我使用的Spring Boot。Spring Boot会自动帮我挑选spring-kafka应该使用哪个版本合适。 application.yml spring:kafka:producer:# kafka集群地址bootstrap-servers: xx.xx.xx.xxx:9092,xx.xx.xx.xxx:9092,xx.xx.xx.xxx:9092client-id: producer-dev# SASL_PLAINTEXT 接入方式security:protocol: SASL_PLAINTEXT# 反序列化方式key-serializer: org.apache.kafka.common.serialization.StringSerializervalue-serializer: org.apache.kafka.common.serialization.StringSerializerproperties:# SASL 采用 SCRAM-SHA-256 方式sasl:mechanism: SCRAM-SHA-256# jaas配置jaas:options:username: kafkauserpassword: kafkapwdenabled: truelogin-module: org.apache.kafka.common.security.scram.ScramLoginModulecontrol-flag: required以上是关于Spring Kafka的全部配置。下面摘要出来的配置是可以单独配置在配置中心的 topic:# 接收消息的主题配置save: hello_kafka_topic spring:kafka:producer:client-id: producer-dev# kafka集群地址bootstrap-servers: xx.xx.xx.xxx:9092,xx.xx.xx.xxx:9092,xx.xx.xx.xxx:9092# jaas配置jaas:options:username: kafkauserpassword: kafkapwdJava KafkaProducerService.java public interface KafkaProducerService {/*** 转发消息到kafka*/void sendToKafka(String msg);}KafkaProducerServiceImpl.java import cn.com.xxx.service.KafkaProducerService; import lombok.extern.slf4j.Slf4j; import org.apache.kafka.clients.producer.ProducerRecord; import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.kafka.core.KafkaProducerException; import org.springframework.kafka.core.KafkaSendCallback; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.support.SendResult; import org.springframework.stereotype.Service; import org.springframework.util.concurrent.ListenableFuture;import javax.annotation.Resource;/*** 转发消息到kafka*/ RefreshScope Slf4j Service public class KafkaProducerServiceImpl implements KafkaProducerService {Resourceprivate KafkaTemplateString, String kafkaTemplate;/*** kafka接收消息的主题*/Value(${topic.save})private String topic;Overridepublic void sendToKafka(String msg) {log.info(String.format($$$$ Producing message: %s, msg));ProducerRecordString, String recordKafka new ProducerRecord(topic, msg);ListenableFutureSendResultString, String future kafkaTemplate.send(recordKafka);future.addCallback(new KafkaSendCallbackString, String() {Overridepublic void onSuccess(SendResultString, String result) {log.info(成功发消息:{}给Kafka:{}, msg, result);}Overridepublic void onFailure(KafkaProducerException ex) {log.error(发消息:{}给Kafka:{}, msg, recordKafka, ex);}});} } 到这里为止Spring Kafka生产者所有配置就都可以了。这里使用的异步监听kafka回调的方式发送消息。 总结 这里使用Spring Kafka库异回调步给Kafka消息。这里使用的Spring Kafka库是老版本所以这里的使用的回调类是ListenableFuture类。 参考 Spring for Apache Kafka2.8.3Spring for Apache Kafka
http://www.pierceye.com/news/885263/

相关文章:

  • 使用word做网站网络广告的特点有哪些?
  • 网站系统参数设置定制网站的制作流程
  • 做家教网站公司品牌vi设计升级
  • 唯品会网站建设建议浙江网站建设价格费用
  • 网站建设购买深圳有做网站的公司有哪些
  • 网站预算表怎么做网站域名续费怎么续费
  • 宁波建设网站公众号关注编辑网站教程
  • 怎样自己做刷赞网站开发软件需要多少成本
  • 为什么网站之有首页被收录广西两学一做网站
  • 制作网站需要的软件怎么向google提交网站
  • 济南网站的建设公司网站建设征求意见表
  • 小学校园网站建设简介打开网站弹出一张图片 怎么做
  • 做外贸没有网站需要注意什么条件做简历模板的网站都有哪些
  • 铜陵保障性住房和城乡建设网站舞钢市城乡建设局网站
  • 企业网站总承包建设模式关键步骤凡科论文送审平台
  • 石家庄学校网站建设在线定制签名
  • 新泰网站制作公司免费下载百度seo
  • 江苏海宏建设工程有限公司网站免费软件是怎么盈利的
  • 建设网站需要申请什么推广网站排名
  • 怎么看出网站是dede做的网页的响应式布局
  • 中国农村建设网站静安广州网站建设
  • 全国 做网站的企业wordpress+编辑模板
  • 网站开发需要的编程软件有哪些海门住房和城乡建设局网站
  • 南宁上林网站建设交换链接是什么
  • 什么网站做简历好api模式网站开发
  • 网站建设与管理专业好吗网络推广seo培训班
  • 常用网站架构辽宁建设工程信息网审计报告
  • 绿色大气网站模板坪山网站建设公司
  • 网站建设动态wordpress禁止自动升级
  • 网站建设网站建设平台网站建设费计入什么科目比较好