spring boot+kafka整合(未完待续)

springboot版本是2.0.4

在整合过程中,spring boot帮我们把kafka的大部分属性直接带出来了,但是有些不常用的属性,需要通过

spring.kafka.consumer.properties.*

来设置,例如max.partition.fetch.bytes,一次fetch请求,从一个partition中取得的records最大值.

在application.properties中添加kafka扩展属性,

#设置一次fetch记录的最大值2M(2*1024*1024),默认值为1M
spring.kafka.consumer.properties.max.partition.fetch.bytes=2097152

更多配置请参考kafka属性大全

 1 # APACHE KAFKA (KafkaProperties)
 2 spring.kafka.admin.client-id= # ID to pass to the server when making requests. Used for server-side logging.
 3 spring.kafka.admin.fail-fast=false # Whether to fail fast if the broker is not available on startup.
 4 spring.kafka.admin.properties.*= # Additional admin-specific properties used to configure the client.
 5 spring.kafka.admin.ssl.key-password= # Password of the private key in the key store file.
 6 spring.kafka.admin.ssl.keystore-location= # Location of the key store file.
 7 spring.kafka.admin.ssl.keystore-password= # Store password for the key store file.
 8 spring.kafka.admin.ssl.keystore-type= # Type of the key store.
 9 spring.kafka.admin.ssl.protocol= # SSL protocol to use.
10 spring.kafka.admin.ssl.truststore-location= # Location of the trust store file.
11 spring.kafka.admin.ssl.truststore-password= # Store password for the trust store file.
12 spring.kafka.admin.ssl.truststore-type= # Type of the trust store.
13 spring.kafka.bootstrap-servers= # Comma-delimited list of host:port pairs to use for establishing the initial connection to the Kafka cluster.
14 spring.kafka.client-id= # ID to pass to the server when making requests. Used for server-side logging.
15 spring.kafka.consumer.auto-commit-interval= # Frequency with which the consumer offsets are auto-committed to Kafka if ‘enable.auto.commit‘ is set to true.
16 spring.kafka.consumer.auto-offset-reset= # What to do when there is no initial offset in Kafka or if the current offset no longer exists on the server.
17 spring.kafka.consumer.bootstrap-servers= # Comma-delimited list of host:port pairs to use for establishing the initial connection to the Kafka cluster.
18 spring.kafka.consumer.client-id= # ID to pass to the server when making requests. Used for server-side logging.
19 spring.kafka.consumer.enable-auto-commit= # Whether the consumer‘s offset is periodically committed in the background.
20 spring.kafka.consumer.fetch-max-wait= # Maximum amount of time the server blocks before answering the fetch request if there isn‘t sufficient data to immediately satisfy the requirement given by "fetch.min.bytes".
21 spring.kafka.consumer.fetch-min-size= # Minimum amount of data, in bytes, the server should return for a fetch request.
22 spring.kafka.consumer.group-id= # Unique string that identifies the consumer group to which this consumer belongs.
23 spring.kafka.consumer.heartbeat-interval= # Expected time between heartbeats to the consumer coordinator.
24 spring.kafka.consumer.key-deserializer= # Deserializer class for keys.
25 spring.kafka.consumer.max-poll-records= # Maximum number of records returned in a single call to poll().
26 spring.kafka.consumer.properties.*= # Additional consumer-specific properties used to configure the client.
27 spring.kafka.consumer.ssl.key-password= # Password of the private key in the key store file.
28 spring.kafka.consumer.ssl.keystore-location= # Location of the key store file.
29 spring.kafka.consumer.ssl.keystore-password= # Store password for the key store file.
30 spring.kafka.consumer.ssl.keystore-type= # Type of the key store.
31 spring.kafka.consumer.ssl.protocol= # SSL protocol to use.
32 spring.kafka.consumer.ssl.truststore-location= # Location of the trust store file.
33 spring.kafka.consumer.ssl.truststore-password= # Store password for the trust store file.
34 spring.kafka.consumer.ssl.truststore-type= # Type of the trust store.
35 spring.kafka.consumer.value-deserializer= # Deserializer class for values.
36 spring.kafka.jaas.control-flag=required # Control flag for login configuration.
37 spring.kafka.jaas.enabled=false # Whether to enable JAAS configuration.
38 spring.kafka.jaas.login-module=com.sun.security.auth.module.Krb5LoginModule # Login module.
39 spring.kafka.jaas.options= # Additional JAAS options.
40 spring.kafka.listener.ack-count= # Number of records between offset commits when ackMode is "COUNT" or "COUNT_TIME".
41 spring.kafka.listener.ack-mode= # Listener AckMode. See the spring-kafka documentation.
42 spring.kafka.listener.ack-time= # Time between offset commits when ackMode is "TIME" or "COUNT_TIME".
43 spring.kafka.listener.client-id= # Prefix for the listener‘s consumer client.id property.
44 spring.kafka.listener.concurrency= # Number of threads to run in the listener containers.
45 spring.kafka.listener.idle-event-interval= # Time between publishing idle consumer events (no data received).
46 spring.kafka.listener.log-container-config= # Whether to log the container configuration during initialization (INFO level).
47 spring.kafka.listener.monitor-interval= # Time between checks for non-responsive consumers. If a duration suffix is not specified, seconds will be used.
48 spring.kafka.listener.no-poll-threshold= # Multiplier applied to "pollTimeout" to determine if a consumer is non-responsive.
49 spring.kafka.listener.poll-timeout= # Timeout to use when polling the consumer.
50 spring.kafka.listener.type=single # Listener type.
51 spring.kafka.producer.acks= # Number of acknowledgments the producer requires the leader to have received before considering a request complete.
52 spring.kafka.producer.batch-size= # Default batch size in bytes.
53 spring.kafka.producer.bootstrap-servers= # Comma-delimited list of host:port pairs to use for establishing the initial connection to the Kafka cluster.
54 spring.kafka.producer.buffer-memory= # Total bytes of memory the producer can use to buffer records waiting to be sent to the server.
55 spring.kafka.producer.client-id= # ID to pass to the server when making requests. Used for server-side logging.
56 spring.kafka.producer.compression-type= # Compression type for all data generated by the producer.
57 spring.kafka.producer.key-serializer= # Serializer class for keys.
58 spring.kafka.producer.properties.*= # Additional producer-specific properties used to configure the client.
59 spring.kafka.producer.retries= # When greater than zero, enables retrying of failed sends.
60 spring.kafka.producer.ssl.key-password= # Password of the private key in the key store file.
61 spring.kafka.producer.ssl.keystore-location= # Location of the key store file.
62 spring.kafka.producer.ssl.keystore-password= # Store password for the key store file.
63 spring.kafka.producer.ssl.keystore-type= # Type of the key store.
64 spring.kafka.producer.ssl.protocol= # SSL protocol to use.
65 spring.kafka.producer.ssl.truststore-location= # Location of the trust store file.
66 spring.kafka.producer.ssl.truststore-password= # Store password for the trust store file.
67 spring.kafka.producer.ssl.truststore-type= # Type of the trust store.
68 spring.kafka.producer.transaction-id-prefix= # When non empty, enables transaction support for producer.
69 spring.kafka.producer.value-serializer= # Serializer class for values.
70 spring.kafka.properties.*= # Additional properties, common to producers and consumers, used to configure the client.
71 spring.kafka.ssl.key-password= # Password of the private key in the key store file.
72 spring.kafka.ssl.keystore-location= # Location of the key store file.
73 spring.kafka.ssl.keystore-password= # Store password for the key store file.
74 spring.kafka.ssl.keystore-type= # Type of the key store.
75 spring.kafka.ssl.protocol= # SSL protocol to use.
76 spring.kafka.ssl.truststore-location= # Location of the trust store file.
77 spring.kafka.ssl.truststore-password= # Store password for the trust store file.
78 spring.kafka.ssl.truststore-type= # Type of the trust store.
79 spring.kafka.template.default-topic= # Default topic to which messages are sent.

官方文档地址:

https://docs.spring.io/spring-boot/docs/2.0.4.RELEASE/reference/htmlsingle/#common-application-properties

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px "Helvetica Neue" }

原文地址:https://www.cnblogs.com/lixyu/p/9404144.html

时间: 2024-08-01 18:51:08

spring boot+kafka整合(未完待续)的相关文章

spring基础知识,未完待续

https://blog.csdn.net/slow_wakler/article/details/54895508 http://www.runoob.com/design-pattern/chain-of-responsibility-pattern.html https://www.cnblogs.com/alwayswyy/p/4904448.html?utm_source=tuicool&utm_medium=referral https://www.cnblogs.com/zmhso

Spring集成Activemq使用(未完待续)

现在任何一个框架的使用都会结合spring框架,quartz.cxf与平时常见的Hibernate.mybatis.Struts等都可以与spring集成起来使用,在这里研究了activemq结合spring的使用方法. 1.理论篇 spring集成JMS连接ActiveMq ConnectionFactory:用于管理连接的工厂(Spring为我们提供的连接池,因为JmsTemplate每次发消息都会重新创建连接.会话和producer,这个操作非常消耗性能,所以Spring提供了连接池) s

Spring Boot/Angular整合Keycloak实现单点登录

未完待续 Keycloak Keycloak为现代应用和服务提供开源的认证和访问管理,即通常所说的认证和授权.Keycloak支持OpenID.OAuth 2.0和SAML 2.0协议:支持用户注册.用户管理.权限管理:支持代理OpenID.SAML 2.0 IDP,支持GitHub.LinkedIn等第三方登录,支持整合LDAP和Active Directory:支持自定义认证流程.自定义用户界面,支持国际化. Keycloak支持Java.C#.Python.Android.iOS.Java

Rabbit MQ和Spring Boot的整合

消息服务 背景:有时需与其它系统集成来完成相关业务功能,原始的做法是程序内部相互调用,除此之外,还可用消息服务中间件来进行业务处理,使用消息服务中间件处理业务能够提升系统的异步通信和扩展解耦的能力,个人有点面向切面的意思. 一.为什么要使用消息服务? 因为它有很多好处,能解决很多问题: 1.异步处理 2.流量消峰 3.提高效率和可靠性 二.RabbitMQ消息中间件的原理和工作模式 RabbitMQ消息中间件的原理: 1.消息发布者P向RabbitMQ代理(Broker)指定虚拟主机服务器发送消

听风讲MVC丶 —— 一言不合就撸码 (未完待续······)

     希望你看了此小随 可以实现自己的MVC框架     也祝所有的程序员身体健康一切安好                                                                                                                                                ——久伴深海丶默 1.什么是前端控制器(font controller).Java Web中的前端控制器是应用的门面,

Linux 命令个人总结====== 未完待续 个人认为比较重要

Linux 命令个人总结====== 未完待续 man [功能说明]: 查看帮助 [语法格式]: man [123456789] 命令.文件. [选项参数]: 数字"1"表示用户命令,比如"ls" 数字"2"表示系统调用 数字"3"表示C语言库函数 数字"4"表示设备或特殊文件 数字"5"表示文件格式和规则 数字"6"表示游戏及其他 数字"7"表示

Spring Boot 应用系列 5 -- Spring Boot 2 整合logback

上一篇我们梳理了Spring Boot 2 整合log4j2的配置过程,其中讲到了Spring Boot 2原装适配logback,并且在非异步环境下logback和log4j2的性能差别不大,所以对于那些日志量不算太高的项目来说,选择logback更简单方便. 1. pom.xml pom.xml不需要添加任何依赖. 2. logback的配置文件 系统启动时,logback按照下列顺序加载第一个找到的配置文件: (1) classpath: logback-test.xml (2) clas

Spring Boot:整合Spring Security

综合概述 Spring Security 是 Spring 社区的一个顶级项目,也是 Spring Boot 官方推荐使用的安全框架.除了常规的认证(Authentication)和授权(Authorization)之外,Spring Security还提供了诸如ACLs,LDAP,JAAS,CAS等高级特性以满足复杂场景下的安全需求.另外,就目前而言,Spring Security和Shiro也是当前广大应用使用比较广泛的两个安全框架. Spring Security 应用级别的安全主要包含两

whatweb.rb 未完待续

#!/usr/bin/env ruby #表示ruby的执行环境 =begin # ruby中用=begin来表示注释的开始 .$$$ $. .$$$ $. $$$$ $$. .$$$ $$$ .$$$$$$. .$$$$$$$$$$. $$$$ $$. .$$$$$$$. .$$$$$$. $ $$ $$$ $ $$ $$$ $ $$$$$$. $$$$$ $$$$$$ $ $$ $$$ $ $$ $$ $ $$$$$$. $ `$ $$$ $ `$ $$$ $ `$ $$$ $$' $ `$