コード例 #1
0
ファイル: push_job.go プロジェクト: huweixuan/goim
// run consume msg.
func run(cg *consumergroup.ConsumerGroup) {
	for msg := range cg.Messages() {
		log.Info("begin deal topic:%s, partitionId:%d, Offset:%d", msg.Topic, msg.Partition, msg.Offset)
		// key eg: cid, value eg: proto.GetReply
		if err := push(int64(binary.BigEndian.Uint64(msg.Key)), msg.Value); err != nil {
			log.Error("push(\"%s\") error(%v), try again", string(msg.Key), err)
		} else {
			log.Info("end delt success, topic:%s, Offset:%d, Key:%d", msg.Topic, msg.Offset, int64(binary.BigEndian.Uint64(msg.Key)))
		}
		cg.CommitUpto(msg)
	}
}