|
|
@ -427,49 +427,62 @@ func (och *OnlineHistoryRedisConsumerHandler) ConsumeClaim(
|
|
|
|
break
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rwLock := new(sync.RWMutex)
|
|
|
|
|
|
|
|
log.ZDebug(context.Background(), "online new session msg come", "highWaterMarkOffset",
|
|
|
|
log.ZDebug(context.Background(), "online new session msg come", "highWaterMarkOffset",
|
|
|
|
claim.HighWaterMarkOffset(), "topic", claim.Topic(), "partition", claim.Partition())
|
|
|
|
claim.HighWaterMarkOffset(), "topic", claim.Topic(), "partition", claim.Partition())
|
|
|
|
cMsg := make([]*sarama.ConsumerMessage, 0, 1000)
|
|
|
|
|
|
|
|
t := time.NewTicker(time.Millisecond * 100)
|
|
|
|
split := 1000
|
|
|
|
|
|
|
|
rwLock := new(sync.RWMutex)
|
|
|
|
|
|
|
|
messages := make([]*sarama.ConsumerMessage, 0, 1000)
|
|
|
|
|
|
|
|
ticker := time.NewTicker(time.Millisecond * 100)
|
|
|
|
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
go func() {
|
|
|
|
for {
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
select {
|
|
|
|
case <-t.C:
|
|
|
|
case <-ticker.C:
|
|
|
|
if len(cMsg) > 0 {
|
|
|
|
if len(messages) == 0 {
|
|
|
|
rwLock.Lock()
|
|
|
|
continue
|
|
|
|
ccMsg := make([]*sarama.ConsumerMessage, 0, 1000)
|
|
|
|
|
|
|
|
for _, v := range cMsg {
|
|
|
|
|
|
|
|
ccMsg = append(ccMsg, v)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cMsg = make([]*sarama.ConsumerMessage, 0, 1000)
|
|
|
|
|
|
|
|
|
|
|
|
rwLock.Lock()
|
|
|
|
|
|
|
|
buffer := make([]*sarama.ConsumerMessage, 0, len(messages))
|
|
|
|
|
|
|
|
buffer = append(buffer, messages...)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// reuse slice, set cap to 0
|
|
|
|
|
|
|
|
messages = messages[:0]
|
|
|
|
rwLock.Unlock()
|
|
|
|
rwLock.Unlock()
|
|
|
|
split := 1000
|
|
|
|
|
|
|
|
|
|
|
|
start := time.Now()
|
|
|
|
ctx := mcontext.WithTriggerIDContext(context.Background(), utils.OperationIDGenerator())
|
|
|
|
ctx := mcontext.WithTriggerIDContext(context.Background(), utils.OperationIDGenerator())
|
|
|
|
log.ZDebug(ctx, "timer trigger msg consumer start", "length", len(ccMsg))
|
|
|
|
log.ZDebug(ctx, "timer trigger msg consumer start", "length", len(buffer))
|
|
|
|
for i := 0; i < len(ccMsg)/split; i++ {
|
|
|
|
for i := 0; i < len(buffer)/split; i++ {
|
|
|
|
// log.Debug()
|
|
|
|
|
|
|
|
och.msgDistributionCh <- Cmd2Value{Cmd: ConsumerMsgs, Value: TriggerChannelValue{
|
|
|
|
och.msgDistributionCh <- Cmd2Value{Cmd: ConsumerMsgs, Value: TriggerChannelValue{
|
|
|
|
ctx: ctx, cMsgList: ccMsg[i*split : (i+1)*split],
|
|
|
|
ctx: ctx, cMsgList: buffer[i*split : (i+1)*split],
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (len(ccMsg) % split) > 0 {
|
|
|
|
if (len(buffer) % split) > 0 {
|
|
|
|
och.msgDistributionCh <- Cmd2Value{Cmd: ConsumerMsgs, Value: TriggerChannelValue{
|
|
|
|
och.msgDistributionCh <- Cmd2Value{Cmd: ConsumerMsgs, Value: TriggerChannelValue{
|
|
|
|
ctx: ctx, cMsgList: ccMsg[split*(len(ccMsg)/split):],
|
|
|
|
ctx: ctx, cMsgList: buffer[split*(len(buffer)/split):],
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.ZDebug(ctx, "timer trigger msg consumer end", "length", len(ccMsg))
|
|
|
|
|
|
|
|
}
|
|
|
|
log.ZDebug(ctx, "timer trigger msg consumer end",
|
|
|
|
|
|
|
|
"length", len(buffer), "time_cost", time.Since(start),
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
for msg := range claim.Messages() {
|
|
|
|
for msg := range claim.Messages() {
|
|
|
|
rwLock.Lock()
|
|
|
|
if len(msg.Value) == 0 {
|
|
|
|
if len(msg.Value) != 0 {
|
|
|
|
continue
|
|
|
|
cMsg = append(cMsg, msg)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rwLock.Lock()
|
|
|
|
|
|
|
|
messages = append(messages, msg)
|
|
|
|
rwLock.Unlock()
|
|
|
|
rwLock.Unlock()
|
|
|
|
|
|
|
|
|
|
|
|
sess.MarkMessage(msg, "")
|
|
|
|
sess.MarkMessage(msg, "")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|