-
Notifications
You must be signed in to change notification settings - Fork 1
/
sampleApp.scala
60 lines (46 loc) · 1.79 KB
/
sampleApp.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.wintersoldier
import org.apache.spark.sql.{DataFrame, SparkSession}
object sampleApp
{
implicit val spark: SparkSession = SparkSession
.builder()
.appName("sampleApp")
.master("local[2]")
.getOrCreate()
import spark.implicits._
// spark.sparkContext.setCheckpointDir("/home/wintersoldier/Desktop/checkpoint")
spark.sparkContext.setLogLevel("ERROR")
def main(array: Array[String]): Unit = {
val brokerUrl: String = "tcp://localhost:61616"
val topicName: String = "sample_topic3"
val username: String = "username"
val password: String = "password"
val connectionType: String = "activemq"
val clientId: String = "coldplay"
val acknowledge: String = "false"
val readInterval: String = "2000"
val queueName : String = "sampleQ"
implicit val df: DataFrame = spark
.readStream
.format("com.wintersoldier.linkinJMS")
.option("connection", connectionType)
.option("brokerUrl", brokerUrl)
// .option("topic", topicName)
.option("queue", queueName)
.option("username", username)
.option("password", password)
.option("acknowledge", acknowledge)
.option("clientId", clientId)
.option("readInterval", readInterval)
.load()
df.writeStream
// .option("checkpointLocation", "/home/wintersoldier/Desktop/checkpoint")
.foreachBatch((batch: DataFrame, batchID: Long) => {
println("The batch ID is: " + batchID)
batch.show()
})
.start
.awaitTermination()
spark.close()
}
}