concurrent consumption of messages

This commit is contained in:
Gordon 2022-05-20 15:28:36 +08:00
parent aa733542e3
commit a2f7edcbcd
2 changed files with 4 additions and 4 deletions

View File

@ -116,7 +116,7 @@ func (och *OfflineHistoryConsumerHandler) MessagesDistributionHandle() {
oldM = append(oldM, &msgFromMQ) oldM = append(oldM, &msgFromMQ)
UserAggregationMsgs[string(consumerMessages[i].Key)] = oldM UserAggregationMsgs[string(consumerMessages[i].Key)] = oldM
} else { } else {
m := make([]*pbMsg.MsgDataToMQ, 50, 100) m := make([]*pbMsg.MsgDataToMQ, 0, 100)
m = append(m, &msgFromMQ) m = append(m, &msgFromMQ)
UserAggregationMsgs[string(consumerMessages[i].Key)] = m UserAggregationMsgs[string(consumerMessages[i].Key)] = m
} }
@ -276,7 +276,7 @@ func (OfflineHistoryConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) erro
func (och *OfflineHistoryConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession, func (och *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("", "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, 200, 500) cMsg := make([]*sarama.ConsumerMessage, 0, 500)
t := time.NewTicker(time.Duration(500) * time.Millisecond) t := time.NewTicker(time.Duration(500) * time.Millisecond)
var triggerID string var triggerID string
for msg := range claim.Messages() { for msg := range claim.Messages() {

View File

@ -231,7 +231,7 @@ func (och *OnlineHistoryConsumerHandler) MessagesDistributionHandle() {
oldM = append(oldM, &msgFromMQ) oldM = append(oldM, &msgFromMQ)
UserAggregationMsgs[string(consumerMessages[i].Key)] = oldM UserAggregationMsgs[string(consumerMessages[i].Key)] = oldM
} else { } else {
m := make([]*pbMsg.MsgDataToMQ, 50, 100) m := make([]*pbMsg.MsgDataToMQ, 0, 100)
m = append(m, &msgFromMQ) m = append(m, &msgFromMQ)
UserAggregationMsgs[string(consumerMessages[i].Key)] = m UserAggregationMsgs[string(consumerMessages[i].Key)] = m
} }
@ -385,7 +385,7 @@ 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
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, 200, 500) cMsg := make([]*sarama.ConsumerMessage, 0, 500)
t := time.NewTicker(time.Duration(500) * time.Millisecond) t := time.NewTicker(time.Duration(500) * time.Millisecond)
var triggerID string var triggerID string
for msg := range claim.Messages() { for msg := range claim.Messages() {