mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Merge remote-tracking branch 'origin/tuoyun' into tuoyun
This commit is contained in:
commit
35a184827a
@ -49,7 +49,7 @@ kafka:
|
|||||||
topic: "ms2ps_chat"
|
topic: "ms2ps_chat"
|
||||||
consumergroupid:
|
consumergroupid:
|
||||||
msgToMongo: mongo
|
msgToMongo: mongo
|
||||||
MsgToMongoOffline: mongo_offline
|
msgToMongoOffline: mongo_offline
|
||||||
msgToMySql: mysql
|
msgToMySql: mysql
|
||||||
msgToPush: push
|
msgToPush: push
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/kafka"
|
"Open_IM/pkg/common/kafka"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/statistics"
|
"Open_IM/pkg/statistics"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
@ -27,8 +28,10 @@ var (
|
|||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
cmdCh = make(chan Cmd2Value, 10000)
|
cmdCh = make(chan Cmd2Value, 10000)
|
||||||
|
w = new(sync.Mutex)
|
||||||
persistentCH.Init()
|
persistentCH.Init()
|
||||||
historyCH.Init(cmdCh)
|
historyCH.Init(cmdCh)
|
||||||
|
log.Debug("come msg transfer ts", config.Config.Kafka.ConsumerGroupID.MsgToMongoOffline, config.Config.Kafka.Ws2mschatOffline.Topic)
|
||||||
offlineHistoryCH.Init(cmdCh)
|
offlineHistoryCH.Init(cmdCh)
|
||||||
statistics.NewStatistics(&singleMsgSuccessCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d second singleMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
|
statistics.NewStatistics(&singleMsgSuccessCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d second singleMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
|
||||||
statistics.NewStatistics(&groupMsgCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d second groupMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
|
statistics.NewStatistics(&groupMsgCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d second groupMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
|
||||||
|
@ -98,19 +98,24 @@ func (OfflineHistoryConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error
|
|||||||
func (OfflineHistoryConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
|
func (OfflineHistoryConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
|
||||||
func (mc *OfflineHistoryConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession,
|
func (mc *OfflineHistoryConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession,
|
||||||
claim sarama.ConsumerGroupClaim) error { // a instance in the consumer group
|
claim sarama.ConsumerGroupClaim) error { // a instance in the consumer group
|
||||||
log.NewDebug("", "new session msg come", claim.HighWaterMarkOffset(), claim.Topic(), claim.Partition())
|
|
||||||
select {
|
|
||||||
case cmd := <-mc.cmdCh:
|
|
||||||
if cmd.Cmd == OnlineTopicVacancy {
|
|
||||||
for msg := range claim.Messages() {
|
|
||||||
if GetOnlineTopicStatus() == OnlineTopicVacancy {
|
|
||||||
log.NewDebug("", "kafka get info to mongo", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value))
|
|
||||||
mc.msgHandle[msg.Topic](msg.Value, string(msg.Key))
|
|
||||||
sess.MarkMessage(msg, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
log.NewDebug("", "new session msg come", claim.HighWaterMarkOffset(), claim.Topic(), claim.Partition())
|
||||||
|
for msg := range claim.Messages() {
|
||||||
|
log.NewDebug("", "kafka get info to delay mongo", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", "offline")
|
||||||
|
mc.msgHandle[msg.Topic](msg.Value, string(msg.Key))
|
||||||
}
|
}
|
||||||
|
//select {
|
||||||
|
//case cmd := <-mc.cmdCh:
|
||||||
|
// if cmd.Cmd == OnlineTopicVacancy {
|
||||||
|
// for msg := range claim.Messages() {
|
||||||
|
// if GetOnlineTopicStatus() == OnlineTopicVacancy {
|
||||||
|
// log.NewDebug("", "kafka get info to mongo", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value))
|
||||||
|
// mc.msgHandle[msg.Topic](msg.Value, string(msg.Key))
|
||||||
|
// sess.MarkMessage(msg, "")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ func (och *OnlineHistoryConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupS
|
|||||||
och.TriggerCmd(OnlineTopicBusy)
|
och.TriggerCmd(OnlineTopicBusy)
|
||||||
SetOnlineTopicStatus(OnlineTopicBusy)
|
SetOnlineTopicStatus(OnlineTopicBusy)
|
||||||
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))
|
log.NewDebug("", "kafka get info to mongo", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "online")
|
||||||
och.msgHandle[msg.Topic](msg.Value, string(msg.Key))
|
och.msgHandle[msg.Topic](msg.Value, string(msg.Key))
|
||||||
sess.MarkMessage(msg, "")
|
sess.MarkMessage(msg, "")
|
||||||
if claim.HighWaterMarkOffset()-msg.Offset <= 1 {
|
if claim.HighWaterMarkOffset()-msg.Offset <= 1 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user