Documentation

You are viewing the documentation for the 2.9.1 release in the 2.9.x series of releases. The latest stable release series is 3.0.x.

§What’s new in Play 2.8

This page highlights the new features of Play 2.8. If you want to learn about the changes you need to make when you migrate to Play 2.8, check out the Play 2.8 Migration Guide.

§Akka 2.6

Play 2.8 brings the latest minor version of Akka. Although Akka 2.6 is binary compatible with 2.5, there are changes in the default configurations, and some deprecated features were removed. You can see more details about the changes in Akka 2.6 migration guide.

§Akka Typed

§Cluster Sharding for Akka Typed

Play 2.8 provides dependency injection support for Akka Cluster Sharding Typed, allowing users to inject a ClusterSharding instance and start sharded typed actors across an Akka Cluster.

§Jackson 2.10 and new ObjectMapper configuration

Jackson dependency was updated to the latest minor release, 2.10.

Moreover, instead of providing its way to create and configure an ObjectMapper, which before Play 2.8 requires the user to write a custom binding, Play now uses Akka Jackson support to provide an ObjectMapper. So, it is now possible to add Jackson Modules and configure Features using application.conf. For example, if you want to add Joda support, you only need to add the following configuration:

akka.serialization.jackson.play.jackson-modules += "com.fasterxml.jackson.datatype.joda.JodaModule"

And if you need to write numbers as strings, add the following configuration:

akka.serialization.jackson.play.serialization-features.WRITE_NUMBERS_AS_STRINGS=true

§Guice support for Akka Actor Typed

The pre-existing AkkaGuiceSupport utility, which helped bind Akka’s “classic” actors, has gained additional methods to support Akka 2.6’s new Typed Actor API.

Here’s a quick example, in Scala, of defining a Guice module which binds a HelloActor:

object AppModule extends AbstractModule with AkkaGuiceSupport {
  override def configure() = {
    bindTypedActor(HelloActor(), "hello-actor")
  }
}

And again, in Java, where the actor extends Akka’s Java DSL AbstractBehavior:

public final class AppModule extends AbstractModule
    implements AkkaGuiceSupport {
  @Override
  protected void configure() {
    bindTypedActor(HelloActor.class, "hello-actor");
  }
}

See Integrating with Akka Typed for more details.

§Java 11 support

Play 2.8.0 is the first version were we officially support Java 11. Play, its standalone modules, samples and seeds are all tested against AdoptOpenJDK 8 & 11. We continue to support Java 8 as the default version.

§Other additions

§Support pre-seek Sources for Range Results

In some cases, it is possible to pre-seek the Source when returning results for requests containing a Range header. For example, if the application is using Alpakka S3 connector, it will efficiently download only the section specified by the Range header. See more details in Java and Scala documentation.

§Build additions

Because Akka does not allow mixing versions, when adding Akka modules to your application, it is important to use a consistent version for all them. To make that easier, play.core.PlayVersion object now has an akkaVersion variable that you can use it in your builds like:

import play.core.PlayVersion.akkaVersion

libraryDependencies += "com.typesafe.akka" %% "akka-cluster" % akkaVersion

It is now possible to configure a max age for language cookie. To do that, add the following to your application.conf:

play.i18n.langCookieMaxAge = 15 seconds

By default, the configuration is null, meaning no max age will be set for Lang cookie.

§Threshold for the gzip filter

If gzip filter is enabled, it is now possible to set a byte threshold to control which responses are gzipped based on their body size. To do that, add the following configuration in application.conf:

play.filters.gzip.threshold = 1k

Responses whose body size is equal or lower than the given byte threshold are then not compressed since the compressed size be larger than the original body.

If the body size cannot be determined (for example, chunked responses), then it is assumed the response is over the threshold.

By default, the threshold is set to 0 (zero) to compress all responses, no matter how large the response body size is.

Please see the gzip filter page for more details.

Next: Migration Guides