mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-26 19:46:57 +08:00
mongo consumer
This commit is contained in:
parent
651c904aff
commit
2043abb24b
@ -46,7 +46,6 @@ func StartTransfer(prometheusPort int) error {
|
|||||||
client, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
|
client, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
|
||||||
openKeeper.WithFreq(time.Hour), openKeeper.WithRoundRobin(), openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.UserName,
|
openKeeper.WithFreq(time.Hour), openKeeper.WithRoundRobin(), openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.UserName,
|
||||||
config.Config.Zookeeper.Password), openKeeper.WithTimeout(10))
|
config.Config.Zookeeper.Password), openKeeper.WithTimeout(10))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -100,14 +100,14 @@ func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(ctx context.Cont
|
|||||||
func (OnlineHistoryMongoConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
|
func (OnlineHistoryMongoConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
|
||||||
func (OnlineHistoryMongoConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
|
func (OnlineHistoryMongoConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
|
||||||
func (mc *OnlineHistoryMongoConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error { // a instance in the consumer group
|
func (mc *OnlineHistoryMongoConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error { // a instance in the consumer group
|
||||||
log.NewDebug("", "online new session msg come", claim.HighWaterMarkOffset(), claim.Topic(), claim.Partition())
|
log.ZDebug(context.Background(), "online new session msg come", "highWaterMarkOffset",
|
||||||
|
claim.HighWaterMarkOffset(), "topic", claim.Topic(), "partition", claim.Partition())
|
||||||
for msg := range claim.Messages() {
|
for msg := range claim.Messages() {
|
||||||
log.NewDebug("", "kafka get info to mongo", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value), "key", string(msg.Key))
|
ctx := mc.historyConsumerGroup.GetContextFromMsg(msg)
|
||||||
if len(msg.Value) != 0 {
|
if len(msg.Value) != 0 {
|
||||||
ctx := mc.historyConsumerGroup.GetContextFromMsg(msg)
|
|
||||||
mc.handleChatWs2Mongo(ctx, msg, string(msg.Key), sess)
|
mc.handleChatWs2Mongo(ctx, msg, string(msg.Key), sess)
|
||||||
} else {
|
} else {
|
||||||
log.Error("", "mongo msg get from kafka but is nil", msg.Key)
|
log.ZError(ctx, "mongo msg get from kafka but is nil", nil, "key", msg.Key)
|
||||||
}
|
}
|
||||||
sess.MarkMessage(msg, "")
|
sess.MarkMessage(msg, "")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user