-
Notifications
You must be signed in to change notification settings - Fork 8
/
StreamRunner.scala
38 lines (27 loc) · 1017 Bytes
/
StreamRunner.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
package persistence
import akka.actor.{ActorSystem, Props, _}
import akka.pattern.ask
import akka.util.Timeout
import persistence.actor.BasketActor
import persistence.commands.{AddItemCommand, RemoveItemCommand}
import persistence.request.GetItemsRequest
import scala.concurrent.Await
import scala.concurrent.duration._
import scala.language.postfixOps
/**
* Created by pabloperezgarcia on 03/02/2017.
*/
object StreamRunner extends App {
implicit val timeout = Timeout(10 seconds)
val system = ActorSystem("Politrons-persistence")
val basketActor = system.actorOf(Props(new BasketActor("akka-persistence-1")))
basketActor ! AddItemCommand("cola")
basketActor ! AddItemCommand("pepsi")
basketActor ! AddItemCommand("doritos")
basketActor ! RemoveItemCommand("pepsi")
basketActor ! AddItemCommand("budweiser")
basketActor ! RemoveItemCommand("cola")
val basket = Await.result(basketActor ? GetItemsRequest, timeout.duration)
println(s"Basket:$basket")
basketActor ! PoisonPill
}