使用golang kafka sarama 包时,遇到如下问题:

高并发情况下使用同步sync producer,偶尔遇到crash:

panic: interface conversion: interface {} is nil, not chan *sarama.ProducerError

goroutine 413 [running]:

github.com/Shopify/sarama.(*syncProducer).handleSuccesses(0xc420384840)

/home/lanyang/github.com/Shopify/sarama/sync_producer.go:147 +0x139

github.com/Shopify/sarama.handleSuccesses)-fm()

/home/lanyang/src/github.com/Shopify/sarama/sync_producer.go:76 +0x2f

github.com/Shopify/sarama.withRecover(0xc4201d0750)

/home/lanyang/src/github.com/Shopify/sarama/utils.go:43 +0x45

created by github.com/Shopify/sarama.newSyncProducerFromAsyncProducer

/home/lanyang/src/github.com/Shopify/sarama/sync_producer.go:76 +0x112

问题不容易复现,github上已经留言:

https://github.com/Shopify/sarama/issues/785

download

https://github.com/Shopify/sarama

https://shopify.github.io/sarama/

doc

https://godoc.org/github.com/Shopify/sarama

依赖

github.com/davecgh/go-spew

github.com/eapache/go-resiliency

github.com/eapache/go-xerial-snappy

github.com/eapache/queue

github.com/pierrec/lz4

github.com/pierrec/xxHash

github.com/rcrowley/go-metrics

github.com/golang/snappy

如果kafka down掉,又恢复,client 可自动连接上。

异步方式,网络断开后,仍然会从queue,放入producer的channel中,重连后,这些内容丢失。

例子参考

sync

http://legendtkl.com/2016/06/30/kafka-in-action/

https://studygolang.com/articles/7102

async

https://studygolang.com/articles/11199

panic: interface conversion: interface {} is nil, not chan *sarama.ProducerError的更多相关文章

  1. go中interface空指针不为nil判断方法

    interface空指针不为nil 当把一个空指针对象赋值给一个interface后,再判断!= nil就不再成立了 代码如下 package main import "fmt" ...

  2. 【Go入门教程6】interface(interface类型、interface值、空interface{}、嵌入interface、反射)

    interface Go语言里面设计最精妙的应该算interface,它让面向对象,内容组织实现非常的方便,当你看完这一章,你就会被interface的巧妙设计所折服. 什么是interface 简单 ...

  3. 【Go入门教程8】interface(interface类型、interface值、空interface{}、嵌入interface、反射)

    interface Go语言里面设计最精妙的应该算interface,它让面向对象,内容组织实现非常的方便,当你看完这一章,你就会被interface的巧妙设计所折服. 什么是interface 简单 ...

  4. golang interface判断为空nil

    要判断interface 空的问题,首先看下其底层实现. interface 底层结构 根据 interface 是否包含有 method,底层实现上用两种 struct 来表示:iface 和 ef ...

  5. panic: reflect.Value.Interface: cannot return value obtained from unexported field or method

    go的结构体中私有的属性, 即使反射也获取不到

  6. Libsvm:脚本(subset.py、grid.py、checkdata.py) | MATLAB/OCTAVE interface | Python interface

    1.脚本 This directory includes some useful codes: 1. subset selection tools. (子集抽取工具) subset.py 2. par ...

  7. Unity Interface Serialization-Expose Interface field In Inspector

    Unity has some quirks about their inspector, so as a preface they are listed here: If you add a [Ser ...

  8. Java abstract interface与 interface的区别

    我们常常遇到abstract class与 interface的区别,今天却遇到了abstract interface,感觉interface不用abstract再修饰了啊.结论:事实也确实如此,编译 ...

  9. 深度解密Go语言之关于 interface 的10个问题

    目录 1. Go 语言与鸭子类型的关系 2. 值接收者和指针接收者的区别 方法 值接收者和指针接收者 两者分别在何时使用 3. iface 和 eface 的区别是什么 4. 接口的动态类型和动态值 ...

随机推荐

  1. RocketMQ之双Master方式部署以及简单使用

    1.1.服务器环境 192.168.100.24 root nameServer1,brokerServer1 Master1 192.168.100.25 root nameServer2,brok ...

  2. [python学习笔记] 运算符

    数学运算符 与大多语言相同的运算符就不介绍了.不同的地方会用 (!不同)标出 与java相同的运算符 , - , * , % , / 不同之处 除法 (!不同) /  与java不同,整数相除,结果为 ...

  3. [js高手之路] es6系列教程 - 迭代器与生成器详解

    什么是迭代器? 迭代器是一种特殊对象,这种对象具有以下特点: 1,所有对象都有一个next方法 2,每次调用next方法,都会返回一个对象,该对象包含两个属性,一个是value, 表示下一个将要返回的 ...

  4. 【个人笔记】《知了堂》MySQL三种关系:一对一,一对多,多对多。

    一对一:比如一个学生对应一个身份证号.学生档案: 一对多:一个班可以有很多学生,但是一个学生只能在一个班: 多对多:一个班可以有很多学生,学生也可以有很多课程: 一对多关系处理: 我们以学生和班级之间 ...

  5. spring boot / cloud (十八) 使用docker快速搭建本地环境

    spring boot / cloud (十八) 使用docker快速搭建本地环境 在平时的开发中工作中,环境的搭建其实一直都是一个很麻烦的事情 特别是现在,系统越来越复杂,所需要连接的一些中间件也越 ...

  6. 如何关闭eclipse对js xml的验证

    经常会发现导入一些js框架,eclipse会编译报错 这是eclipse对js的瞎验证,如何解决呢? 关闭eclipse对js,xml的验证即可: 菜单Window - > Preference ...

  7. 2013 ACM/ICPC Asia Regional Chengdu Online hdu4731 Minimum palindrome

    Minimum palindrome Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  8. 【京东个人中心】——Nodejs/Ajax/HTML5/Mysql爬坑之注册与登录监听

    一.引言 在数据库和静态页面都创建好之后,下面就该接着完成后台Node.js监听注册和登录的部分了.这个部分主要使用的技术是:Node.js的Express框架和ajax异步请求.登录和注册的代码实现 ...

  9. 初学者易上手的SSH-struts2 01环境搭建

    首先,SSH不是一个框架,而是多个框架(struts+spring+hibernate)的集成,是目前较流行的一种Web应用程序开源集成框架,用于构建灵活.易于扩展的多层Web应用程序. 集成SSH框 ...

  10. Asp.Net MVC4 系列-- 进阶篇之路由(1)

    创建一个路由 打开 RouteConfig.cs  ,发现已经创建了一个默认路由 : routes.MapRoute( name:"Default", url:"{con ...