Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Akka stream 2.6. How to create ActorMaterializer?

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?

like image 628
Alexander Kondaurov Avatar asked Nov 08 '19 14:11

Alexander Kondaurov


People also ask

What is ActorMaterializer?

ActorMaterializer is responsible for providing materialization to the Akka Toolkit. It will create all the required Actors under the hood and take care of executing the data streams with defined functionality. It needs the ActorSystem to create and manage those Actors.

Can you describe what are 3 main components of Akka streams?

Akka streams consist of 3 major components in it – Source, Flow, Sink – and any non-cyclical stream consist of at least 2 components Source, Sink and any number of Flow element.

What is backpressure in Akka?

In other words, data flows through the graph as a response to demand from receivers. Producers then comply and send more elements downstream. A second (transparent) protocol kicks in when production of elements is faster than demand. This protocol (backpressure) slows down the producers and ensures no data is lost.

What is Materializer Akka?

Actor Materializer Lifecycle. The Materializer is a component that is responsible for turning the stream blueprint into a running stream and emitting the “materialized value”.


1 Answers

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
like image 159
Ivan Stanislavciuc Avatar answered Oct 17 '22 10:10

Ivan Stanislavciuc