Using Apache Pekko actors and GPars actors with Groovy

submited by
Style Pass
2024-11-26 16:30:06

Apache Pekko is an Apache-licensed fork of the Akka project (based on Akka version 2.6.x) and provides a framework for building applications that are concurrent, distributed, resilient and elastic. Pekko provides high-level abstractions for concurrency based on actors, as well as additional libraries for persistence, streams, HTTP, and more. It provides Scala and Java APIs/DSLs for writing your applications. We’ll be using the latter. We’ll look at just one example of using Pekko actors.

By way of comparison, we’ll also be looking at GPars, a concurrency library for Java and Groovy with support for actors, agents, concurrent & parallel map/reduce, fork/join, asynchronous closures, dataflow, and more. A previous blog post looks at additional features of GPars and how to use it with virtual threads. Here, we’ll just look at the comparable actor features for our Pekko example.

A common first example involving actors involves creating two actors where one actor sends a message to the second actor which sends a reply back to the first. We could certainly do that, but we’ll use a slightly more interesting example involving three actors. The example comes from the Pekko documentation and is illustrated in the following diagram (from the Pekko documentation):

Leave a Comment