spring+springmvc+kafka分布式消息中间件集成方案

onghu的消息服务平台已经抛弃了之前的ActiveMQ,改用高吞吐量比较大的Kafka分布式消息中间件方案:
kafka消息平台使用spring+kafka的集成方案,详情如下:
1. 使用最高版本2.1.0.RELEASE集成jar包:spring-integration-kafka


2. Zookeeper、Kafka分布式集群使用init.properties配置化方案。

 

Java代码 :

  1. kafka.servers=127.0.0.1:9092    
  2. kafka.topic=xxxooo  

 
3. 使用消息生产者spring-context-producer配置化方案。

 

Java代码 :

  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.      xmlns:context="http://www.springframework.org/schema/context"    
  5.      xsi:schemaLocation="http://www.springframework.org/schema/beans    
  6.          http://www.springframework.org/schema/beans/spring-beans.xsd    
  7.          http://www.springframework.org/schema/context    
  8.          http://www.springframework.org/schema/context/spring-context.xsd">   
  9.   
  10.   
  11.     <!-- 定义producer的参数 -->  
  12.     <bean id="producerProperties" class="java.util.HashMap">  
  13.         <constructor-arg>  
  14.             <map>  
  15.                 <entry key="bootstrap.servers" value="localhost:9092" />  
  16.                 <entry key="group.id" value="2" />  
  17.                 <entry key="retries" value="10" />  
  18.                 <entry key="batch.size" value="16384" />  
  19.                 <entry key="linger.ms" value="1" />  
  20.                 <entry key="buffer.memory" value="3355
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值