2. About me
• Java since 1997
• Scala since 2010
• Mostly backend systems
• Lead architect Traffic Management at CSC
• Akka committer
code: http://github.com/RayRoestenburg
blog: http://roestenburg.agilesquad.com
twtr: @RayRoestenburg
3. Company I work for
Traffic Management
• Section Control
• Weigh in Motion
• Traffic Information
• Traffic Enforcement
6. Sensor networks
• Usable for many applications in our field
• Distributed along highways and provincial roads
• Traffic Enforcement
• Traffic Information
• Other applications
• Roadside systems
• Range of sensor types
– Camera’s, Infrared, Laser, Piezoelectric, Loops, Mobile
units, …
• Remotely Configure & Control
7. Why Scala & Akka
• Less code, less bugs
• Less code, same VM power
• Experienced team (Java, C#, C)
• 3 experienced Java devs
• 1 experienced C# dev with no Java experience
• Need to interoperate with existing Java and
C (JNA)
• Simplify development (C->Java->Scala)
• Ubuntu
8. Scala 2.9.x
• Learning curve (Start with simple features)
• Traits, Tupels, Stackable Traits
• First Class Functions
• Scala Collections
• map, flatMap, partition, foreach, filter, groupBy..
• Option type
• map.. orElse, foreach,..
• Case classes
• REPL, DSLs, Extension methods
9. Typesafe Stack
• Current Stack
• Open Source
• SBT 0.7.7
• Scala 2.9.0-1
• Akka 1.1.3
• Camel & Camel Components 2.7.0
(FTP,Mina,Jetty,…)
• Jboss Netty 3.2.4
• When we started early 2010
• Akka 0.7, Scala 2.8.0Beta1
25. Dispatchers
Camel Producers Local Processing Camel Consumers
Heartbeat, Remote Actors
Cleanup,
Schedule,
Long Running,
Redelivery,
Remote Error Handling
26. Messages
• Case classes
• Simple data containers
• toProtobuf and fromProtobuf on case class
and companion object for remoting
• Every msg has a
• correlation Id to the event
• Timestamp
• Logging, Tracing, Performance
30. Remote Actors (Akka 1.1.3)
• JBoss Netty (Channels)
• Not as transparent as you would like
• Remote Lifecycle Listeners
• Closing sockets, reconnect
• Own Guaranteed Delivery implementation
– Specific requirements
– Bases on Idempotent Receiver and Repeating
messages after reconnect
– Non-Trivial
– Heartbeats
– Exp Backoff
31. Remote configuration
• #compression-scheme = "zlib“ #leave out
• zlib-compression-level = 0
• client: reconnection-time-window = 2000000
• client: read-timeout (we use 60)
• backlog = 4096 # Netty backlog for
connections, should suffice, increase if
failures happen
32. Monitoring
• Application level monitoring
• Listener Actors contain Custom JMX MBeans
• Direct passthrough of msg or translation
ActorRef is an immutable reference which exclusively gives access to the Actor.Actors run on Dispatchers. A Dispatcher runs a mailbox to process messages.Amount of messages per mailbox run is configurable. (actor.throughput, default 5)
One way messaging between two ActorsActors can process messages in parallel
One way messaging between two ActorsActors can process messages in parallel
!!! Is preferred over !!Futuresalso run onDispatchers.FutureTimeoutException happens onfuture.get. IfonlyonComplete and failure are registered, yougetnoFutureTimeoutException