Last year this session’s speaker and his colleagues started a new Internet of Things project: Internet of (Lego) Trains. They wanted to figure out if they could use Java or Scala/Akka on IoT hardware. The Lego trains are equipped with a Raspberry Pi, camera, wireless dongle, infrared transmitter, speaker, RFID reader, and battery pack. Next to that are automated switch tracks and cameras, again with the help of Raspberry Pi’s. To control the trains and other parts, they built an actor-based application with Scala, Akka, Akka HTTP, and AngularJS. The session covers when and how to use Akka HTTP and remote actors to create a new generation of applications. It also presents the results of the performance tests they did to compare the two options. A live demo is of course included.
8. MINIMAL INGREDIENTS FOR 1TRAIN
ABOUT € 50
Raspberry Pi A+ / Raspberry Pi Zero
Wifi dongle
EDUP Ultra-Mini Nano USB 2.0 802.11n
USB battery pack
Anker® 2. Gen Astro Mini 3200mAh
Infrared transmitter
Keyes 38KHz IR InfraredTransmitter Module for
Arduino
28. AKKA ACTORS
class Worker extends Actor {
def receive = {
case x =>
println(x)
}
}
val system = ActorSystem("ExampleActorSystem")
val workerActorRef = system.actorOf(Props[Worker])
workerActorRef ! "Hello conference"
31. AKKA REMOTE ACTOR CALL
val workerActorRef =
system.actorOf(Props[Worker])
val workerActorRef =
system.actorSelection("akka.tcp://
ExampleActorSystem@127.0.0.1:9005
/user/workerActor")
32. AKKA REMOTE ACTOR CONFIGURATION
akka {
actor {
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
netty.tcp {
hostname = "127.0.0.1"
port = 9002
}
}
}
38. MESSAGE USED BY APPLICATION
val actorRef = context.actorSelection(
"akka.tcp://[Actorsystem]@
[IP]:[port]/user/musicservice")
actorRef !
[packagename].MusicServiceMessage.Play(filename)
You can also make it a bit bigger with camera, RFID, speaker
You could use a Zero or Particle Photon if you only need an IR transmitter. But for video it’s a bit more difficult to use those. Bigger is better for development speed. Smaller is better to put it in a train.
This is the test setup for the performance test
JVM1 is the frontend, receives http request from client
JVM1 sends a request to JVM2 for some further info, after reply from JVM2 it responds to the client.
Top is over HTTP
Bottom is using Akka remote actors over TCP.
Documentation
Raspberry USB connector/burned
Hardware resources
To small children
Time
Limited resources although quite a lot with the Raspberry Pi. This HD only has 72 MB
Broken Raspberry Pi USB connector on A+
Lego quite picky with batteries, empty batteries. No easy/cheap way to charge Lego battery box.
RFID only works when nearby and when moving slowly
WIFI issues
No plug and play
Lots of options: Raspbian/Arch. Docker, documentation, support, hardware
Documentation, wiring etc.
To small children
Not enough time
Sum up
Play with lego;s like kids
Show and tells for grownups
Testdrive akka, experience
Come to Jfokus in beaty stockholm
… That’s not even the best part. The best part is …
Ervaring opgedaan met hardware/IoT
Java en Scala/Akka werken blijkbaar prima
- Marketing stands op conferenties
Scala/Akka ervaring REST vs Remote Actors
Ons hier gebracht