...
|
...
|
@@ -124,4 +124,70 @@ |
|
|
<entry key="channelUserServiceImpl" value-ref="channelUserServiceImpl"/>
|
|
|
</util:map>
|
|
|
|
|
|
|
|
|
<!-- kafka consumer -->
|
|
|
<!-- 定义consumer的参数 -->
|
|
|
<bean id="consumerProperties" class="java.util.HashMap">
|
|
|
<constructor-arg>
|
|
|
<map>
|
|
|
<entry key="bootstrap.servers" value="${bootstrap-consumer.servers}" />
|
|
|
<entry key="group.id" value="data2qq__consumer__1" />
|
|
|
<entry key="enable.auto.commit" value="false"/>
|
|
|
<entry key="key.deserializer" value="org.apache.kafka.common.serialization.StringDeserializer" />
|
|
|
<entry key="value.deserializer" value="org.apache.kafka.common.serialization.StringDeserializer" />
|
|
|
</map>
|
|
|
</constructor-arg>
|
|
|
</bean>
|
|
|
|
|
|
<!-- 创建consumerFactory bean -->
|
|
|
<bean id="kafkaConsumerFactory" class="org.springframework.kafka.core.DefaultKafkaConsumerFactory">
|
|
|
<constructor-arg>
|
|
|
<ref bean="consumerProperties" />
|
|
|
</constructor-arg>
|
|
|
</bean>
|
|
|
|
|
|
<bean id="kafkaConsumer" class="com.yoho.unions.server.mqconsumer.KafkaConsumer">
|
|
|
|
|
|
</bean>
|
|
|
|
|
|
<!-- 消费者容器配置信息 -->
|
|
|
<bean id="containerProperties" class="org.springframework.kafka.listener.config.ContainerProperties">
|
|
|
<constructor-arg name="topics" value="yoho_log_mobile" /> <!-- yoho_log_mobile/test -->
|
|
|
<property name="messageListener" ref="kafkaConsumer" />
|
|
|
</bean>
|
|
|
|
|
|
<bean id="messageListenerContainer" class="org.springframework.kafka.listener.KafkaMessageListenerContainer"
|
|
|
init-method="doStart">
|
|
|
<constructor-arg ref="kafkaConsumerFactory" />
|
|
|
<constructor-arg ref="containerProperties" />
|
|
|
</bean>
|
|
|
<!-- kafka consumer -->
|
|
|
|
|
|
<!-- 定义producer的参数 -->
|
|
|
<bean id="producerProperties" class="java.util.HashMap">
|
|
|
<constructor-arg>
|
|
|
<map>
|
|
|
<entry key="bootstrap.servers" value="${bootstrap-producer.servers}" />
|
|
|
<entry key="group.id" value="0" />
|
|
|
<entry key="key.serializer" value="org.apache.kafka.common.serialization.StringSerializer" />
|
|
|
<entry key="value.serializer" value="org.apache.kafka.common.serialization.StringSerializer" />
|
|
|
</map>
|
|
|
</constructor-arg>
|
|
|
</bean>
|
|
|
|
|
|
<!-- 创建kafkatemplate需要使用的producerfactory bean -->
|
|
|
<bean id="producerFactory" class="org.springframework.kafka.core.DefaultKafkaProducerFactory">
|
|
|
<constructor-arg>
|
|
|
<ref bean="producerProperties" />
|
|
|
</constructor-arg>
|
|
|
</bean>
|
|
|
|
|
|
<!-- 创建kafkatemplate bean,使用的时候,只需要注入这个bean,即可使用template的send消息方法 -->
|
|
|
<bean id="KafkaTemplate" class="org.springframework.kafka.core.KafkaTemplate">
|
|
|
<constructor-arg ref="producerFactory" />
|
|
|
<constructor-arg name="autoFlush" value="true" />
|
|
|
<property name="defaultTopic" value="yoho_log_mobile" /> <!-- yoho_log_mobile/test -->
|
|
|
</bean>
|
|
|
<!--kafak product-->
|
|
|
|
|
|
</beans> |
...
|
...
|
|