How to Build Stateful Java Services in 15 Minutes or Less

by Brad Johnson, on Jun 7, 2019 12:11:52 PM

Five years ago when I started tracking media buzz around stateful architectures, I’d see a few articles every month about running stateful containers. That's about when Caitie McCaffrey first shared this awesome presentation about building scalable stateful architectures. Since then, the dominant software paradigm has become functional application design. The actor model and other object-oriented paradigms are still in use, but database-centric RESTful architectures are standard means of building web applications today.

However, the tides are beginning to shift. Due to innovations like the blockchain, growing demand for real-time applications, the digitization of OT assets, and the proliferation of cheap compute resources at the network edge; there’s renewed interest in decentralized application architectures. As such, there’s also been increased focus on stateful applications. For example, at least five Apache Foundation projects (Beam, Flink, Spark, Samza, and TomEE) are touting statefulness as a benefit today. Modern applications communicate across multiple application silos and must span real-world machines, devices, and distributed data centers around the world. Stateful application architectures provide a way to abstract away the logistical effort of state management, thereby reducing development and management effort necessary to operate massive-scale distributed applications.

Build a Scalable, Stateful To-Do List in 15 Minutes or Less

Swim to-do list app screenshot

For the rest of this post, I want to disprove the notion that building scalable, stateful applications is a task too complex for everyday Java developers. In order to illustrate how easily a stateful application can be setup, we’ll walk through a tutorial for building a simple to-do list using the Swim platform. You can find all the source code for the to-do list tutorial here on GitHub.

Getting Started: Setting Up Your Development Environment

Before diving into the to-do list app itself, it’s important to ensure your development environment is properly setup to run Swim applications.

To run the to-do list example application, only  Java 9 and the Gradle build tool (though this is handled by our wrapper script) are required. This video tutorial goes through the process of setting up your local Swim development environment: 



Tutorial: How to Build a Simple, Stateful To-Do List App Using Swim

Once your development environment is setup, you’re ready to build a stateful to-do list. The to-do list example is quite basic, but the same patterns can be applied to Swim applications of any complexity. As I mentioned earlier in the post, all the code for the to-do list example app is available on GitHub.

Finally, if you’re ready to get started building your own stateful to-do list application, check out this tutorial video:



Learn More

Let us know your thoughts about this tutorial and what you're building on the open source Swim platform.

You can get started with Swim here and make sure to STAR us on GitHub.

Topics:SWIM AIdistributed computingHTTPweb applicationsswimOSmiddlewareRESTWARPstreamingoperating systemsnodejsweb agentsapistreaming apitutorialjava