Created
October 27, 2016 04:52
-
-
Save daschl/63098d1ce7406a73f0557b797ffad2e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create the Spark Config and instruct to use the travel-sample bucket | |
// with no password. | |
val conf = new SparkConf() | |
.setMaster("local[*]") | |
.setAppName("StreamingExample") | |
.set("com.couchbase.bucket.travel-sample", "") | |
// Initialize StreamingContext with a Batch interval of 5 seconds | |
val ssc = new StreamingContext(conf, Seconds(5)) | |
// Consume the DCP Stream from the beginning and never stop. | |
// This counts the messages per interval and prints their count. | |
ssc | |
.couchbaseStream(from = FromBeginning, to = ToInfinity) | |
.count() | |
.print() | |
// Start the Stream and await termination | |
ssc.start() | |
ssc.awaitTermination() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment