zoukankan      html  css  js  c++  java
  • 多线程消息监听容器配置[ 消费者spring-kafka配置文件]

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <beans xmlns="http://www.springframework.org/schema/beans"
     3        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     4        xsi:schemaLocation="http://www.springframework.org/schema/beans
     5          http://www.springframework.org/schema/beans/spring-beans.xsd">
     6 
     7 
     8     <bean id="consumerProperties" class="java.util.HashMap">
     9         <constructor-arg>
    10             <map>
    11                 <entry key="bootstrap.servers" value="${bootstrap.servers}"/>
    12                 <!-- 指定消费组名 -->
    13                 <entry key="group.id" value="friend-group"/>
    14                 <entry key="enable.auto.commit" value="true"/>
    15                 <entry key="auto.commit.interval.ms" value="1000"/>
    16                 <entry key="session.timeout.ms" value="15000"/>
    17                 <entry key="max.poll.records" value="1"/>
    18                 <entry key="key.deserializer" value="org.apache.kafka.common.serialization.IntegerDeserializer"/>
    19                 <!--<entry key="key.deserializer" value="org.apache.kafka.common.serialization.StringDeserializer"/>-->
    20                 <entry key="value.deserializer" value="org.apache.kafka.common.serialization.StringDeserializer"/>
    21             </map>
    22         </constructor-arg>
    23     </bean>
    24 
    25     <bean id="consumerFactory" class="org.springframework.kafka.core.DefaultKafkaConsumerFactory">
    26         <constructor-arg>
    27             <ref bean="consumerProperties"/>
    28         </constructor-arg>
    29     </bean>
    30 
    31     <!-- 消费消息的服务类 -->
    32     <bean id="messageListernerConsumerService" class="com.zhaopin.consumer.ConsumerService"/>
    33 
    34     <!-- 消费者容器配置信息 -->
    35     <bean id="containerProperties" class="org.springframework.kafka.listener.config.ContainerProperties">
    36         <constructor-arg value="friend"/>
    37         <!--<constructor-arg>
    38             <list>
    39                 <value>zptopic</value>
    40                 <value>ssmk</value>
    41                 <value>friend</value>
    42             </list>
    43         </constructor-arg>-->
    44         <property name="messageListener" ref="messageListernerConsumerService"/>
    45     </bean>
    46 
    47     <!-- 单线程消息监听容器 -->
    48     <!--<bean id="messageListenerContainer" class="org.springframework.kafka.listener.KafkaMessageListenerContainer" init-method="doStart">
    49         <constructor-arg ref="consumerFactory"/>
    50         <constructor-arg ref="containerProperties"/>
    51     </bean>-->
    52 
    53     <!-- 多线程消息监听容器 -->
    54     <bean id="messageListenerContainer" class="org.springframework.kafka.listener.ConcurrentMessageListenerContainer" init-method="doStart">
    55         <constructor-arg ref="consumerFactory"/>
    56         <constructor-arg ref="containerProperties"/>
    57         <property name="concurrency" value="5"/>
    58     </bean>
    59 
    60 </beans>
  • 相关阅读:
    寒假短期学习计划
    PAT 1001 A+B 解题报告
    JavaScript 原型链、继承
    JavaScript 数据扁平化处理
    每周一篇React: 高阶 hoc_component 使用
    每天一道算法题: day1 翻转图像
    项目中下载加权,你是怎么做的,欢迎评论。
    前端封装验证码方法,封装验证码类
    文件下载之后默认不打开实现方式
    文件下载之后默认不打开实现方式
  • 原文地址:https://www.cnblogs.com/jun1019/p/6628618.html
Copyright © 2011-2022 走看看