main.go 874 字节
package main

import (
	"github.com/Shopify/sarama"
	saramaConsumer "github.com/linmadan/egglib-go/mom/kafka/sarama"
	"gitlab.fjmaimaimai.com/mmm-go-pp/egglib-go-demos/message/kafka/sarama/sub/messageHandler"
	_ "gitlab.fjmaimaimai.com/mmm-go-pp/egglib-go-demos/orm/go-pg"
	"gitlab.fjmaimaimai.com/mmm-go-pp/egglib-go-demos/pkg/constant"
	"gitlab.fjmaimaimai.com/mmm-go-pp/egglib-go-demos/pkg/log"
)

func main() {
	messageHandlerMap := make(map[string]func(message *sarama.ConsumerMessage) error)
	// 方法1 直接引用
	// messageHandlerMap[constant.PUSH_MESSAGE_TOPIC] = messageHandler.PushMessageCommandHandler
	// 方法2 函数包装
	messageHandlerMap[constant.PUSH_MESSAGE_TOPIC] = messageHandler.PgWrapperConsumerHandler(messageHandler.PushMessageHandler)
	saramaConsumer.StartConsume(constant.KAFKA_HOSTS, constant.SERVICE_NAME, messageHandlerMap, log.Logger)
}