kafka 使用说明(spring boot)


springboot kafka 使用说明

 

********************************

自动配置类使用参数

 

@ConfigurationProperties(
    prefix = "spring.kafka"
)
public class KafkaProperties {
    private List bootstrapServers = new ArrayList(Collections.singletonList("localhost:9092"));
    private String clientId;
    private final Map properties = new HashMap();
    private final KafkaProperties.Consumer consumer = new KafkaProperties.Consumer();
    private final KafkaProperties.Producer producer = new KafkaProperties.Producer();
    private final KafkaProperties.Admin admin = new KafkaProperties.Admin();
    private final KafkaProperties.Streams streams = new KafkaProperties.Streams();
    private final KafkaProperties.Listener listener = new KafkaProperties.Listener();
    private final KafkaProperties.Ssl ssl = new KafkaProperties.Ssl();
    private final KafkaProperties.Jaas jaas = new KafkaProperties.Jaas();

****************************
producer:发送者配置参数

    public static class Producer {
        private final KafkaProperties.Ssl ssl = new KafkaProperties.Ssl();
        private String acks;        //设置副本同步方式,0:不返回写入状态,
                                                     1:leader副本写入成功即可返回
                                                    -1:ISR集合写入成功后返回
        private DataSize batchSize;
        private List bootstrapServers;
        private DataSize bufferMemory;  //消息累加器的空间大小
        private String clientId;        //producer id,不设置时,会自动创建,如producer-1
        private String compressionType; //压缩类型,默认为none,即不压缩,可设置为gzip、snappy、lz4
        private Class keySerializer = StringSerializer.class;
        private Class valueSerializer = StringSerializer.class;
        private Integer retries;             //重试次数
        private String transactionIdPrefix;  //设置后,可发送事物消息
        private final Map properties = new HashMap();


************************
consumer:消费者配置参数

    public static class Consumer {
        private final KafkaProperties.Ssl ssl = new KafkaProperties.Ssl();
        private Duration autoCommitInterval;  //自动提交位移的时间间隔
        private String autoOffsetReset;       //设置启动后拉取消息的位置
        private List bootstrapServers;
        private String clientId;
        private Boolean enableAutoCommit;      //位移自动提交
        private Duration fetchMaxWait;
        private DataSize fetchMinSize;
        private String groupId;                //消费者所属的组
        private Duration heartbeatInterval;    //向group coordinator发送心跳的时间间隔
        private IsolationLevel isolationLevel; //事物消息的隔离级别,默认为读未提交
        private Class keyDeserializer;      //如果不设置,默认为StringDeserializer
        private Class valueDeserializer;    //如果不设置,默认为StringDeserializer
        private Integer maxPollRecords;
        private final Map properties;

        public Consumer() {
            this.isolationLevel = IsolationLevel.READ_UNCOMMITTED;
            this.keyDeserializer = StringDeserializer.class;
            this.valueDeserializer = StringDeserializer.class;
            this.properties = new HashMap();
        }


**********************************
listener:消费监听配置参数

    public static class Listener {
        private KafkaProperties.Listener.Type type;
                                        //消费类型,单条消费、批量消费
        private AckMode ackMode;        //位移提交方式
        private String clientId;
        private Integer concurrency;
        private Duration pollTimeout;
        private Float noPollThreshold;
        private Integer ackCount;       //自动提交时消费指定次数后提交
        private Duration ackTime;       //自动提交时,指定时间间隔后提交
        private Duration idleEventInterval;
        @DurationUnit(ChronoUnit.SECONDS)
        private Duration monitorInterval;
        private Boolean logContainerConfig;
        private boolean missingTopicsFatal;


********************************
admin

    public static class Admin {
        private final KafkaProperties.Ssl ssl = new KafkaProperties.Ssl();
        private String clientId;
        private final Map properties = new HashMap();
        private boolean failFast;


*********************************
steams

    public static class Streams {
        private final KafkaProperties.Ssl ssl = new KafkaProperties.Ssl();
        private String applicationId;
        private boolean autoStartup = true;
        private List bootstrapServers;
        private DataSize 

你可能感兴趣的:(kafka,kafka,使用说明)