Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing output kafka the same reqID message goes to the same partition. #1250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion output_kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ func (o *KafkaOutput) ErrorHandler() {
// PluginWrite writes a message to this plugin
func (o *KafkaOutput) PluginWrite(msg *Message) (n int, err error) {
var message sarama.StringEncoder
meta := payloadMeta(msg.Meta)
msgKey := sarama.StringEncoder(meta[1])

if !o.config.UseJSON {
message = sarama.StringEncoder(byteutils.SliceToString(msg.Meta) + byteutils.SliceToString(msg.Data))
Expand All @@ -74,7 +76,6 @@ func (o *KafkaOutput) PluginWrite(msg *Message) (n int, err error) {
header[k] = strings.Join(v, ", ")
}

meta := payloadMeta(msg.Meta)
req := msg.Data

kafkaMessage := KafkaMessage{
Expand All @@ -93,6 +94,7 @@ func (o *KafkaOutput) PluginWrite(msg *Message) (n int, err error) {
o.producer.Input() <- &sarama.ProducerMessage{
Topic: o.config.Topic,
Value: message,
Key: msgKey,
}

return len(message), nil
Expand Down
Loading