mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-13 16:47:36 +08:00
kafka msg data conversion
This commit is contained in:
parent
183ee60620
commit
b336241271
@ -22,6 +22,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
topic = "latestMsgToRedis"
|
topic = "latestMsgToRedis"
|
||||||
addr = "127.0.0.1:9092"
|
addr = "127.0.0.1:9092"
|
||||||
|
//addr = "43.128.72.19:9092"
|
||||||
)
|
)
|
||||||
|
|
||||||
var consumer sarama.Consumer
|
var consumer sarama.Consumer
|
||||||
@ -77,10 +78,8 @@ func GetMessage() {
|
|||||||
fmt.Printf("failed to start consumer for partition %d,err:%v\n", partition, err)
|
fmt.Printf("failed to start consumer for partition %d,err:%v\n", partition, err)
|
||||||
}
|
}
|
||||||
// Asynchronously consume information from each partition
|
// Asynchronously consume information from each partition
|
||||||
go func(sarama.PartitionConsumer) {
|
for msg := range pc.Messages() {
|
||||||
for msg := range pc.Messages() {
|
fmt.Printf("Partition:%d Offset:%d Key:%v Value:%v", msg.Partition, msg.Offset, msg.Key, msg.Value)
|
||||||
fmt.Printf("Partition:%d Offset:%d Key:%v Value:%v", msg.Partition, msg.Offset, msg.Key, msg.Value)
|
}
|
||||||
}
|
|
||||||
}(pc)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user