Akka stream 2.6. How to create ActorMaterializer?
Asked Answered
H

1

27

Since 2.6 i get deprecation warning on this line:

import akka.stream.ActorMaterializer
implicit val actorMaterializer = ActorMaterializer()

Warning:

method apply in object ActorMaterializer is deprecated (since 2.6.0): Use the system wide materializer with stream attributes or configuration settings to change defaults

I don't understand that message, what am i supposed to do? What's 'system wide materializer', it it located in some akka package?

Holinshed answered 8/11, 2019 at 14:24 Comment(0)
P
44

It's not needed anymore. But you have to have an implicit of ActorSystem available in your context.

implicit val actorSystem = ActorSystem()

Then the materializer is implicitly derived from ActorSystem in akka.stream.Materializer

  /**
   * Implicitly provides the system wide materializer from a classic or typed `ActorSystem`
   */
  implicit def matFromSystem(implicit provider: ClassicActorSystemProvider): Materializer =
    SystemMaterializer(provider.classicSystem).materializer
Paquette answered 8/11, 2019 at 14:29 Comment(2)
Yeah, but you need to have akka-stream as dependency.Dinger
@Dinger why would you need a Materializer if you don't use akka streams?Caravan

© 2022 - 2024 — McMap. All rights reserved.