-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed as not planned
Labels
staleIssues and pull requests without any recent activityIssues and pull requests without any recent activity
Description
Versions
Please specify real version numbers or git SHAs, not just "Latest" since that changes fairly regularly.
Sarama | Kafka | Go |
---|---|---|
v1.34.0 | wurstmeister/kafka:2.11-1.1.0 | 1.17 |
Configuration
What configuration values are you using for Sarama and Kafka?
package main
import (
"encoding/json"
"fmt"
kingpin "gopkg.in/alecthomas/kingpin.v2"
"github.com/Shopify/sarama"
)
type Order struct {
OrderId string `json:"order_id"`
ProductName string `json:"product_name"`
OrderStatus string `json:"order_status"`
StatusChangeTime string `json:"status_change_time"`
Mobile string `json:"mobile"`
}
const (
// brokerList = "localhost:9092"
// topic = "kafka-test"
)
var (
order []byte
brokerList = kingpin.Flag("brokerList", "List of brokers to connect").Default("127.0.0.1:9092").Strings()
topic = kingpin.Flag("topic", "Topic name").Default("kafka-test").String()
maxRetry = kingpin.Flag("maxRetry", "Retry limit").Default("5").Int()
)
func init() {
order, _ = json.Marshal(&Order{
OrderId: "1",
ProductName: "牙刷",
OrderStatus: "待付款",
StatusChangeTime: "2020-01-01 00:00:00",
Mobile: "1537954106",
})
}
func main() {
kingpin.Parse()
config := sarama.NewConfig()
config.Producer.RequiredAcks = sarama.WaitForAll
config.Producer.Retry.Max = *maxRetry
config.Producer.Return.Successes = true
producer, err := sarama.NewSyncProducer(*brokerList, config)
if err != nil {
panic(err)
}
defer func() {
if err := producer.Close(); err != nil {
panic(err)
}
}()
fmt.Println("order", string(order))
msg := &sarama.ProducerMessage{
Topic: *topic,
Value: sarama.ByteEncoder(order),
}
partition, offset, err := producer.SendMessage(msg)
if err != nil {
panic(err)
}
fmt.Printf("Message is stored in topic(%s)/partition(%d)/offset(%d)\n", *topic, partition, offset)
}
Logs
When filing an issue please provide logs from Sarama and Kafka if at all
possible. You can set sarama.Logger
to a log.Logger
to capture Sarama debug
output.
logs: CLICK ME
panic: kafka server: In the middle of a leadership election, there is currently no leader for this partition and hence it is unavailable for writes
Problem Description
Metadata
Metadata
Assignees
Labels
staleIssues and pull requests without any recent activityIssues and pull requests without any recent activity