You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using this project to bridge NATs messages to Kafka; and we found an issue that if keyType, keyValue and balancer are not specified, it will always produce messages to the same Kafka partition.
func (conn *BridgeConnector) calculateKey(subject string, replyto string) []byte {
keyType := conn.config.KeyType
keyValue := conn.config.KeyValue
if keyType == conf.FixedKey {
return []byte(keyValue)
}
if keyType == conf.SubjectKey {
return []byte(subject)
}
if keyType == conf.ReplyToKey {
return []byte(replyto)
}
if keyType == conf.SubjectRegex {
r, err := regexp.Compile(keyValue)
if err != nil {
conn.bridge.logger.Noticef("invalid regex for %s key value", conn.String())
return []byte{}
}
result := r.FindStringSubmatch(subject)
if len(result) > 1 {
return []byte(result[1])
}
return []byte{}
}
if keyType == conf.ReplyRegex {
r, err := regexp.Compile(keyValue)
if err != nil {
conn.bridge.logger.Noticef("invalid regex for %s key value", conn.String())
return []byte{}
}
result := r.FindStringSubmatch(replyto)
if len(result) > 1 {
return []byte(result[1])
}
return []byte{}
}
return []byte{} // empty key by default
}
In Connector.calculateKey, if keyType is not assigned, an empty array is returned and this will result in NewHashPartitioner fails to return a random partition.
Please help to see if nil shall be returned if keyType is not specified.
Thanks
The text was updated successfully, but these errors were encountered:
Hi,
We are using this project to bridge NATs messages to Kafka; and we found an issue that if keyType, keyValue and balancer are not specified, it will always produce messages to the same Kafka partition.
And we found that IBM/sarama#1957 might be related.
In
Connector.calculateKey
, if keyType is not assigned, an empty array is returned and this will result inNewHashPartitioner
fails to return a random partition.Please help to see if nil shall be returned if keyType is not specified.
Thanks
The text was updated successfully, but these errors were encountered: