A basic example of building a Lagom project to run outside of the Lightbend Production Suite (aka ConductR).
This was initially created from the lagom-java
template (sbt new lagom/lagom-java.g8
), with the following changes:
- Added
ConfigurationServiceLocator
to Guice modules in each implementation project, as described in the Lagom documentation - Added static port bindings to each service (
hello-impl
: 8001,hello-stream-impl
: 8002) - Added a static service location to
hello-impl
forcas_native
(the Cassandra server) - Added a static service location to
hello-stream-impl
forhello
To test this:
- Open a terminal and clone the repository to your workstation (
git clone https://github.com/TimMoore/lagom-sbt-standalone.git
) cd lagom-sbt-standalone
sbt
to enter the sbt consoledist
(from the sbt prompt) to create distribution packageslagomCassandraStart
(from the sbt prompt) to run a Cassandra server on port 4000- Leave sbt running in that terminal window and open two more terminals in the same directory
- In one terminal:
cd hello-impl/target/universal
unzip hello-impl-1.0-SNAPSHOT.zip
(or, if you don't have theunzip
command, use any tool to unzip the file into the same directory)cd hello-impl-1.0-SNAPSHOT
bash bin/hello-impl -Dlagom.cluster.join-self=on
(orbin/hello-impl.bat -Dlagom.cluster.join-self=on
on Windows)
- In the other terminal:
cd hello-stream-impl/target/universal
unzip hello-stream-impl-1.0-SNAPSHOT.zip
cd hello-stream-impl-1.0-SNAPSHOT
bash bin/hello-stream-impl -Dlagom.cluster.join-self=on
(orbin/hello-stream-impl.bat -Dlagom.cluster.join-self=on
on Windows)
This runs each of the services on the configured port, as single-node clusters.
You can press control-C to exit the services, and run lagomCassandraStop
in the initial sbt console to stop Cassandra (or simply exit sbt).
For those looking for a basic example of building a Lagom project, in Scala, to run outside of the Lightbend Production Suite (aka ConductR) follow this link - lagom-scala-sbt-standalone.
This configuration is not suitable for production deployments, it's just intended as a starting point. Here are some of the limitations to be aware of.
- Static service locator configuration is difficult to manage in practice, as it requires configuration to be duplicated across all services, and configuring additional services requires a restart.
- The provided
ConfigurationServiceLocator
only supports a single endpoint per service, which reduces resilience and elasticity. - Using
-Dlagom.cluster.join-self=on
restricts each service to run on a single node. Creating a multi-node cluster requires configuring seed nodes as described in the Lagom Cluster documentation - The provided launcher scripts do not attempt to handle process supervision or health monitoring
Lightbend Production Suite (ConductR) provides easy-to-use solutions to these problems and others.