Posts Tagged ‘SERLI’
[DevoxxFR2015] Reactive Applications on Raspberry Pi: A Microservices Adventure
Alexandre Delègue and Mathieu Ancelin, both engineers at SERLI, captivated attendees at Devoxx France 2015 with a deep dive into building reactive applications on a Raspberry Pi cluster. Leveraging their expertise in Java, Java EE, and open-source projects, they demonstrated a microservices-based system using Play, Akka, Cassandra, and Elasticsearch, testing the Reactive Manifesto’s promises on constrained hardware.
Embracing the Reactive Manifesto
Alexandre opened by contrasting monolithic enterprise stacks with the modular, scalable approach of the Reactive Manifesto. He introduced their application, built with microservices and event sourcing, designed to be responsive, resilient, and elastic. Running this on Raspberry Pi’s limited resources tested the architecture’s ability to deliver under constraints, proving its adaptability.
This philosophy, Alexandre noted, prioritizes agility and resilience.
Microservices and Event Sourcing
Mathieu detailed the application’s architecture, using Play for the web framework and Akka for actor-based concurrency. Cassandra handled data persistence, while Elasticsearch enabled fast search capabilities. Event sourcing ensured a reliable audit trail, capturing state changes as events. The duo’s live demo showcased these components interacting seamlessly, even on low-powered Raspberry Pi hardware.
This setup, Mathieu emphasized, ensures robust performance.
Challenges of Clustering on Raspberry Pi
The session highlighted configuration pitfalls encountered during clustering. Alexandre shared how initial deployments overwhelmed the Raspberry Pi’s CPU, causing nodes to disconnect and form sub-clusters. Proper configuration, tested pre-production, resolved these issues, ensuring stable heartbeats across the cluster. Their experience underscored the importance of thorough setup validation.
These lessons, Alexandre noted, are critical for constrained environments.
Alternative Reactive Approaches
Mathieu explored other reactive libraries, such as Spring Boot with reactive Java 8 features and async servlets, demonstrating versatility beyond Akka. Their demo included Gatling for load testing, though an outdated plugin caused challenges, since resolved natively. The session concluded with a nod to the fun of building such systems, encouraging experimentation.
This flexibility, Mathieu concluded, broadens reactive development options.
Links:
[DevoxxFR2015] React: Rethinking UI Components
Mathieu Ancelin, a Java EE expert at SERLI, introduced React, Facebook’s JavaScript library, at Devoxx France 2015. With a focus on component-based UIs, Mathieu demonstrated how React’s JavaScript-centric approach eliminates templates, enabling reusable, testable interfaces for dynamic applications.
React’s Component-Based Paradigm
Mathieu highlighted React’s departure from traditional templating, using pure JavaScript to define components. This expressiveness supports complex UIs with evolving data, as seen in his Reddit iOS client demo, coded entirely in React with native iOS components. The approach ensures consistency across platforms, aligning with the “learn once, write everywhere” philosophy.
This paradigm, Mathieu argued, simplifies scalable UI development.
Flux for Unidirectional Data Flow
He introduced Flux, a pattern for managing application state with unidirectional data flows. User actions dispatch to stores, updating views via events, ensuring predictable state management. His demo showcased a mobile app, emphasizing React’s versatility beyond HTML to native components.
Mathieu noted Flux enhances application robustness.
Cross-Platform Potential
Despite a demo glitch, Mathieu’s Reddit client illustrated React’s cross-platform capabilities, rendering native iOS elements via JavaScript. Q&A explored Flux implementations, encouraging exploration of tutorials for deeper understanding.
This flexibility positions React as a powerful UI tool.
Links:
[DevoxxFR2013] Soon, in a Galaxy Not So Far Away: Real-Time Web with Play 2, Akka, and Spaceships
Lecturer
Mathieu Ancelin is a software engineer at SERLI, specializing in Java EE technologies with a particular focus on component frameworks. He contributes to open-source projects such as GlassFish, JOnAS, and leads initiatives like CDI-OSGi and Play CDI. A member of the JSR 346 expert group for CDI 1.1, Ancelin regularly teaches at the University of La Rochelle and Poitiers, and speaks at conferences including JavaOne and Solutions Linux. He is active in the Poitou-Charentes JUG and can be followed on Twitter as @TrevorReznik.
Abstract
Mathieu Ancelin demystifies Play 2’s real-time capabilities, answering the perennial question: “WTF are Iteratees?” Through live demonstrations of two playful applications—a multiplayer spaceship battle and a real-time roulette game—he showcases how Play 2 leverages Iteratees, Akka actors, Server-Sent Events (SSE), WebSockets, HTML5 Canvas, and even webcam input to build responsive, interactive web experiences. The session explores how these APIs integrate seamlessly with Java and Scala, enabling developers to create low-latency, event-driven systems using their preferred language. Beyond the fun, Ancelin analyzes architectural patterns for scalability, backpressure handling, and state management in real-time web applications.
Demystifying Iteratees: Functional Streams for Non-Blocking I/O
Ancelin begins by addressing the confusion surrounding Iteratees, a functional reactive programming abstraction in Play 2. Unlike traditional imperative streams, Iteratees separate data production, processing, and consumption, enabling composable, backpressure-aware pipelines.
val enumeratee: Enumeratee[Array[Byte], String] = Enumeratee.map[Array[Byte]].apply[String] { bytes =>
new String(bytes, "UTF-8")
}
This allows safe handling of chunked HTTP input without blocking threads. When combined with Enumerators (producers) and Enumeratees (transformers), they form robust data flows:
val socket: WebSocket[JsValue, JsValue] = WebSocket.using[JsValue] { request =>
val in = Iteratee.foreach[JsValue](msg => actor ! msg).map(_ => actor ! PoisonPill)
val out = Enumerator.fromCallback1(_ => futurePromise.future)
(in, out)
}
Ancelin demonstrates how this pattern prevents memory leaks and thread exhaustion under load.
Akka Actors: Coordinating Game State and Player Actions
The spaceship game uses Akka actors to manage shared game state. A central GameActor maintains positions, velocities, and collisions:
class GameActor extends Actor {
var players = Map.empty[String, Player]
val ticker = context.system.scheduler.schedule(0.millis, 16.millis, self, Tick)
def receive = {
case Join(id, out) => players += (id -> Player(out))
case Input(id, thrust, rotate) => players(id).update(thrust, rotate)
case Tick => broadcastState()
}
}
Each client connects via WebSocket, sending input events and receiving rendered frames. The actor model ensures thread-safe updates and natural distribution.
Real-Time Rendering with Canvas and Webcam Integration
The game renders on HTML5 Canvas using client-side JavaScript. Server pushes state via SSE or WebSocket; client interpolates between ticks for smooth 60 FPS animation.
A bonus feature uses getUserMedia() to capture webcam input, mapping head tilt to ship rotation—an engaging demo of sensor fusion in the browser.
navigator.getUserMedia({ video: true }, stream => {
video.src = URL.createObjectURL(stream);
tracker.on('track', event => sendRotation(event.data.angle));
});
Play Roulette: SSE for Unidirectional Live Updates
The second demo, Play Roulette, uses Server-Sent Events to broadcast spin results to all connected clients:
def live = Action {
Ok.chunked(results via EventSource()).as("text/event-stream")
}
Clients subscribe with:
const es = new EventSource('/live');
es.onmessage = e => updateWheel(JSON.parse(e.data));
This pattern excels for broadcast scenarios—news feeds, dashboards, live sports.
Language Interoperability: Java and Scala Working Together
Ancelin emphasizes Play 2’s dual-language support. Java developers use the same APIs via wrappers:
public static WebSocket<JsonNode> socket() {
return WebSocket.withActor(GameActor::props);
}
This lowers the barrier for Java teams adopting reactive patterns.
Architecture Analysis: Scalability, Fault Tolerance, and Deployment
The system scales horizontally using Akka clustering. Game instances partition by room; a load balancer routes WebSocket upgrades. Failure recovery leverages supervisor strategies.
Deployment uses Play’s dist task to generate start scripts. For production, Ancelin recommends Typesafe ConductR or Docker with health checks.
Implications for Modern Web Applications
Play 2’s real-time stack enables:
– Low-latency UX without polling
– Efficient resource use via non-blocking I/O
– Graceful degradation under load
– Cross-language development in polyglot teams
From games to trading platforms, the patterns apply broadly.
Links:
[DevoxxBE2012] Weld-OSGi in Action
Mathieu Ancelin and Matthieu Clochard, software engineers at SERLI specializing in Java EE and modular systems, showcased the synergy between CDI, OSGi, and Weld in their Weld-OSGi framework during DevoxxBE2012. Mathieu, a member of the CDI 1.1 expert group and contributor to projects like GlassFish, collaborated with Matthieu, who focuses on OSGi integrations, to demonstrate how Weld-OSGi simplifies dynamic application assembly without added complexity.
They started with CDI basics, where dependency injection manages component lifecycles via annotations like @Inject. OSGi’s modularity, with bundles as deployment units and a dynamic service registry, complements this by allowing runtime changes. Weld-OSGi bridges them, enabling CDI beans to interact seamlessly with OSGi services.
A demo illustrated bootstrapping Weld-OSGi in an OSGi environment, registering bundles, and using extensions for event handling. They emphasized transparent service interactions, where CDI observes OSGi events for dynamic updates.
Mathieu and Matthieu highlighted Weld-OSGi’s role in making OSGi accessible, countering perceptions of its difficulty by leveraging CDI’s programming model.
Fundamentals of CDI and OSGi Integration
Mathieu explained CDI’s bean management, scopes, and qualifiers for precise injections. Matthieu detailed OSGi’s bundle lifecycle and service registry, where services publish and consume dynamically.
Weld-OSGi embeds CDI containers in OSGi, using extensions to observe bundle events and register services as beans. This allows injecting OSGi services into CDI components effortlessly.
Dynamic Features and Practical Demonstrations
They demonstrated service dynamism: publishing a service updates dependent beans automatically. Unpublishing triggers alternatives or errors, ensuring robustness.
Demos included hybrid applications where Java EE components interact with OSGi bundles via the registry, deploying parts dynamically without restarts.
Future Prospects and Community Engagement
Mathieu discussed ongoing work for hybrid servers like GlassFish, embedding Weld-OSGi for cleaner integrations. They referenced RFC 146, inspired by Weld-OSGi, for native CDI-OSGi support.
Encouraging trials, they pointed to GitHub repositories with examples and documentation, fostering feedback to evolve the framework.
Mathieu and Matthieu’s presentation illustrated Weld-OSGi’s potential to create fully dynamic modular applications, blending CDI’s elegance with OSGi’s power.