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
Some psuedo code, that doesn't actually work because initTransactions() needs to only be called once
finaldefproduceWithTransaction[T<:Topic, M:Encoder:SchemaFor](
topic: T,
partitionKey: M=>String,
messages: Iterable[M]
)(implicittopicSchema: TopicSchema[T, M]):Future[Iterable[ProducerResult[T, M]]] = {
// This is the workflow documented in http://kafka.apache.org/0110/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html
initTransactions()
try {
beginTransaction()
// TODO: messages.par.map...???Future.sequence(messages.map { m => produce(topic, partitionKey(m), m) }).map{ ret =>
commitTransaction()
ret
}
} catch {
case ex ifProducer.isFatalKafkaException(ex) =>// We can't recover from these exceptions, so our only option is to close the producer and exit.
close()
Future.failed(ex)
caseex: KafkaException=>
abortTransaction()
Future.failed(ex)
}
}
privatedefisFatalKafkaException(ex: Throwable):Boolean= ex match {
case_: ProducerFencedException=>truecase_: OutOfOrderSequenceException=>truecase_: AuthorizationException=>truecase _ =>false
}
The text was updated successfully, but these errors were encountered:
Some psuedo code, that doesn't actually work because
initTransactions()
needs to only be called onceThe text was updated successfully, but these errors were encountered: