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

Fix bug causing random partitions with partition key #23

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions src/main/scala/KafkaProducer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ case class KafkaProducer(

val producer = new Producer[AnyRef, AnyRef](new ProducerConfig(props))

def kafkaMesssage(message: Array[Byte], partition: Array[Byte]): KeyedMessage[AnyRef, AnyRef] = {
def kafkaMesssage(message: List[Byte], partition: List[Byte]): KeyedMessage[AnyRef, AnyRef] = {
if (partition == null) {
new KeyedMessage(topic,message)
} else {
new KeyedMessage(topic,partition,message)
}
}

def send(message: String, partition: String = null): Unit = send(message.getBytes("UTF8"), if (partition == null) null else partition.getBytes("UTF8"))
def send(message: String, partition: String = null): Unit = send(message.getBytes("UTF8").toList, if (partition == null) null else partition.getBytes("UTF8").toList)

def send(message: Array[Byte], partition: Array[Byte]): Unit = {
def send(message: List[Byte], partition: List[Byte]): Unit = {
try {
producer.send(kafkaMesssage(message, partition))
} catch {
Expand Down