Skip to content

Instantly share code, notes, and snippets.

@ElisaBaum
ElisaBaum / Consumer.scala
Last active August 27, 2020 08:06
Kafka Producer/Consumer Example in Scala
import java.util.Properties
import scala.collection.JavaConverters._
import org.apache.kafka.clients.consumer.{ConsumerConfig, ConsumerRecords, KafkaConsumer}
import org.apache.kafka.common.serialization.StringDeserializer
class Consumer(brokers: String, topic: String, groupId: String) {
val consumer = new KafkaConsumer[String, String](configuration)
consumer.subscribe(List(topic).asJava)
@ElisaBaum
ElisaBaum / KMSDecryptionUtil.scala
Last active June 19, 2017 13:34
Util to decrypt AWS KMS encrypted keys
import java.nio.ByteBuffer
import java.nio.charset.Charset
import com.amazonaws.services.kms.AWSKMSClientBuilder
import com.amazonaws.services.kms.model.DecryptRequest
import com.amazonaws.util.Base64
object KMSDecryptionUtil {
private lazy val kmsClient = AWSKMSClientBuilder.defaultClient()