chore: move example test file to examples/queue

This commit is contained in:
qloog
2021-10-19 23:09:28 +08:00
parent f946de43a3
commit 45376e44a5
4 changed files with 132 additions and 144 deletions

View File

@@ -0,0 +1,27 @@
package main
import (
"log"
"os"
"github.com/Shopify/sarama"
"github.com/go-eagle/eagle/pkg/queue/kafka"
)
func main() {
var (
config = sarama.NewConfig()
logger = log.New(os.Stderr, "[sarama_logger]", log.LstdFlags)
groupID = "sarama_consumer"
topic = "go-message-broker-topic"
brokers = []string{"localhost:9093"}
message = "Hello World Kafka!"
)
// kafka publish message
kafka.NewProducer(config, logger, topic, brokers).Publish(message)
// kafka consume message
kafka.NewConsumer(config, logger, topic, groupID, brokers).Consume()
}