<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:apollo="http://www.ctrip.com/schema/apollo"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.ctrip.com/schema/apollo
	   http://www.ctrip.com/schema/apollo.xsd">

    <apollo:config/>
    <bean id="consumerProperties" class="java.util.HashMap">
        <constructor-arg>
            <map>
                <entry key="bootstrap.servers" value="${kafka.service}"/>
                <entry key="group.id" value="haoban-3-sync"/>
                <entry key="key.deserializer"
                       value="org.apache.kafka.common.serialization.StringDeserializer"/>
                <entry key="value.deserializer"
                       value="com.gic.binlog.base.serializer.KafkaGicRecordSerializer"/>
            </map>
        </constructor-arg>
    </bean>
    <!-- 2.创建consumerFactory bean -->
    <bean id="consumerFactory"
          class="org.springframework.kafka.core.DefaultKafkaConsumerFactory">
        <constructor-arg>
            <ref bean="consumerProperties"/>
        </constructor-arg>
    </bean>

    <!-- 3.定义消费实现类 -->
    <bean id="kafkaConsumerService" class="com.gic.haoban.manage.service.task.KafkaMessageServiceImpl"/>

    <!-- 4.消费者容器配置信息 -->
    <bean id="containerProperties" class="org.springframework.kafka.listener.config.ContainerProperties">
        <!-- topic -->
        <constructor-arg name="topics">
            <list>
                <value>haoban_gic_clerk</value>
                <value>haoban_gic_store</value>
                <value>haoban_gic_store_group</value>
            </list>
        </constructor-arg>
        <property name="messageListener" ref="kafkaConsumerService"/>
    </bean>
    <!-- 5.消费者并发消息监听容器，执行doStart()方法 -->
    <bean id="messageListenerContainer" class="org.springframework.kafka.listener.ConcurrentMessageListenerContainer"
          init-method="doStart">
        <constructor-arg ref="consumerFactory"/>
        <constructor-arg ref="containerProperties"/>
        <property name="concurrency" value="3"/>
    </bean>
</beans>