I Have following code :-
val conf = new SparkConf()
.setMaster("local[3]")
.setAppName("KafkaReceiver")
.set("spark.cassandra.connection.host", "192.168.0.78")
.set("spark.cassandra.connection.keep_alive_ms", "20000")
.set("spark.executor.memory", "2g")
.set("spark.driver.memory", "4g")
.set("spark.submit.deployMode", "cluster")
.set("spark.cores.max", "10")
val sc = SparkContext.getOrCreate(conf)
val ssc = new StreamingContext(sc, Seconds(10))
val kafkaParams = Map[String, String](
"bootstrap.servers" -> "192.168.0.1:9092",
"group.id" -> "test-group-aditya")
val topics = Set("random")
val kafkaStream = KafkaUtils.createDirectStream[String, String, StringDecoder, StringDecoder](ssc, kafkaParams, topics)
In this code I'm streaming data from kafka after every 10 seconds but I'm looking for some condition where I can stream based on time or stream size in MB/byte like let say I set 5 MB so if limit reaches 5 MB I should be able to get the data rather then waiting for 10 seconds. Please suggest some solution. Thanks,