项目作者: tal-tech

项目描述 :
Pan is a high performance mq proxy,support kafka,rabbit-mq,rocketmq,nsq and other mq
高级语言: Go
项目地址: git://github.com/tal-tech/pan.git
创建时间: 2020-07-27T03:47:58Z
项目社区:https://github.com/tal-tech/pan

开源协议:Apache License 2.0

下载


" class="reference-link">image-20200803155136931


Background


Pan is a high performance and stable production side agent of messager-oriented middleware written in pure Go language. It supports mainstream message queues in the market, such as Kafka, RabbitMQ, RocketMQ, NSQ, etc. Moreover, it is easy to be extended and can meet different business requirements in the production environment.

Document


Document

中文文档

Framework


The framework of Pan is shown as below.

image-20200803155136931

Quickstart

Produce messages to kafka by Pan.


1. Start zookeeper

  1. ./bin/zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties

2. Start kafka

  1. ./bin/kafka-server-start /usr/local/etc/kafka/server.properties

3. Create topic

  1. ./bin/kafka-topics --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test

4. Modify config for kafka in Pan

  1. [KafkaProxy]
  2. enable=true
  3. KafkaWaitAll=true
  4. KafkaCompression=true
  5. KafkaPartitioner=round
  6. KafkaProducerTimeout=10
  7. brokers=localhost:9092
  8. sasl=false
  9. user=
  10. password=
  11. valid= //topic whitelist,if empty, all topic can be sended
  12. failMode=retry/save/discard

5. Run

  1. tar -zxvf pan.tar.gz
  2. cd pan/
  3. make
  4. ./bin/pan -c ../conf/conf.ini

6. Send Message

  1. package main
  2. import (
  3. "fmt"
  4. "time"
  5. "github.com/tal-tech/xtools/kafkautil"
  6. "github.com/spf13/cast"
  7. )
  8. func main() {
  9. t := time.Tick(5 * time.Second)
  10. count := 0
  11. for {
  12. select {
  13. case <-t:
  14. count++
  15. err := kafkautil.Send2Proxy("test", []byte("kafka "+cast.ToString(count)))
  16. if err != nil {
  17. fmt.Println(err)
  18. }
  19. continue
  20. }
  21. }
  22. }

modify conf

  1. [KafkaProxy]
  2. unix=/home/www/pan/pan.sock //sock in pan
  3. host=localhost:9999 //ip and post pan listen

warn

replace in go.mod

  1. replace github.com/henrylee2cn/teleport v5.0.0+incompatible => github.com/hhtlxhhxy/github.com_henrylee2cn_teleport v1.0.0
  2. replace github.com/henrylee2cn/teleport v0.0.0 => github.com/hhtlxhhxy/github.com_henrylee2cn_teleport v1.0.0

Contact us



Contact Us



(微信扫一扫,申请加入开发讨论微信群)