Merge remote-tracking branch 'origin/tuoyun' into tuoyun

pull/232/head
skiffer-git 3 years ago
commit f1e2704407

@ -389,8 +389,11 @@ func (OnlineHistoryConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error
func (och *OnlineHistoryConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession, func (och *OnlineHistoryConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession,
claim sarama.ConsumerGroupClaim) error { // a instance in the consumer group claim sarama.ConsumerGroupClaim) error { // a instance in the consumer group
if sess == nil {
time.Sleep(100 * time.Millisecond)
}
log.NewDebug("", "online new session msg come", claim.HighWaterMarkOffset(), claim.Topic(), claim.Partition()) log.NewDebug("", "online new session msg come", claim.HighWaterMarkOffset(), claim.Topic(), claim.Partition())
cMsg := make([]*sarama.ConsumerMessage, 0, 500) cMsg := make([]*sarama.ConsumerMessage, 0, 1000)
t := time.NewTicker(time.Duration(100) * time.Millisecond) t := time.NewTicker(time.Duration(100) * time.Millisecond)
var triggerID string var triggerID string
for { for {
@ -398,8 +401,8 @@ func (och *OnlineHistoryConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupS
select { select {
case msg := <-claim.Messages(): case msg := <-claim.Messages():
cMsg = append(cMsg, msg) cMsg = append(cMsg, msg)
if len(cMsg) >= 500 { if len(cMsg) >= 1000 {
ccMsg := make([]*sarama.ConsumerMessage, 0, 500) ccMsg := make([]*sarama.ConsumerMessage, 0, 1000)
for _, v := range cMsg { for _, v := range cMsg {
ccMsg = append(ccMsg, v) ccMsg = append(ccMsg, v)
@ -409,12 +412,12 @@ func (och *OnlineHistoryConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupS
och.msgDistributionCh <- Cmd2Value{Cmd: ConsumerMsgs, Value: TriggerChannelValue{ och.msgDistributionCh <- Cmd2Value{Cmd: ConsumerMsgs, Value: TriggerChannelValue{
triggerID: triggerID, cmsgList: ccMsg}} triggerID: triggerID, cmsgList: ccMsg}}
sess.MarkMessage(msg, "") sess.MarkMessage(msg, "")
cMsg = make([]*sarama.ConsumerMessage, 0, 500) cMsg = make([]*sarama.ConsumerMessage, 0, 1000)
log.Debug(triggerID, "length trigger msg consumer end", len(cMsg)) log.Debug(triggerID, "length trigger msg consumer end", len(cMsg))
} }
case <-t.C: case <-t.C:
if len(cMsg) > 0 { if len(cMsg) > 0 {
ccMsg := make([]*sarama.ConsumerMessage, 0, 500) ccMsg := make([]*sarama.ConsumerMessage, 0, 1000)
for _, v := range cMsg { for _, v := range cMsg {
ccMsg = append(ccMsg, v) ccMsg = append(ccMsg, v)
} }
@ -423,7 +426,7 @@ func (och *OnlineHistoryConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupS
och.msgDistributionCh <- Cmd2Value{Cmd: ConsumerMsgs, Value: TriggerChannelValue{ och.msgDistributionCh <- Cmd2Value{Cmd: ConsumerMsgs, Value: TriggerChannelValue{
triggerID: triggerID, cmsgList: ccMsg}} triggerID: triggerID, cmsgList: ccMsg}}
sess.MarkMessage(cMsg[len(cMsg)-1], "") sess.MarkMessage(cMsg[len(cMsg)-1], "")
cMsg = make([]*sarama.ConsumerMessage, 0, 500) cMsg = make([]*sarama.ConsumerMessage, 0, 1000)
log.Debug(triggerID, "timer trigger msg consumer end", len(cMsg)) log.Debug(triggerID, "timer trigger msg consumer end", len(cMsg))
} }

Loading…
Cancel
Save