pan
pan copied to clipboard
Pan is a high performance mq proxy,support kafka,rabbit-mq,rocketmq,nsq and other mq
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
Framework
The framework of Pan is shown as below.

Quickstart
Produce messages to kafka by Pan.
1. Start zookeeper
./bin/zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties
2. Start kafka
./bin/kafka-server-start /usr/local/etc/kafka/server.properties
3. Create topic
./bin/kafka-topics --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
4. Modify config for kafka in Pan
[KafkaProxy]
enable=true
KafkaWaitAll=true
KafkaCompression=true
KafkaPartitioner=round
KafkaProducerTimeout=10
brokers=localhost:9092
sasl=false
user=
password=
valid= //topic whitelist,if empty, all topic can be sended
failMode=retry/save/discard
5. Run
tar -zxvf pan.tar.gz
cd pan/
make
./bin/pan -c ../conf/conf.ini
6. Send Message
package main
import (
"fmt"
"time"
"github.com/tal-tech/xtools/kafkautil"
"github.com/spf13/cast"
)
func main() {
t := time.Tick(5 * time.Second)
count := 0
for {
select {
case <-t:
count++
err := kafkautil.Send2Proxy("test", []byte("kafka "+cast.ToString(count)))
if err != nil {
fmt.Println(err)
}
continue
}
}
}
modify conf
[KafkaProxy]
unix=/home/www/pan/pan.sock //sock in pan
host=localhost:9999 //ip and post pan listen
warn
replace in go.mod
replace github.com/henrylee2cn/teleport v5.0.0+incompatible => github.com/hhtlxhhxy/github.com_henrylee2cn_teleport v1.0.0
或
replace github.com/henrylee2cn/teleport v0.0.0 => github.com/hhtlxhhxy/github.com_henrylee2cn_teleport v1.0.0
Contact us
(微信扫一扫,申请加入开发讨论微信群)