Federico Saenz
Federico Saenz

Reputation: 532

Cannot resolve method ask - Akka Streaming with Java

I'm experimenting with akka, and (following the documentation), I have the following code:

Source<String, NotUsed> words =
                Source.from(Arrays.asList("hello", "hi"));
        Timeout askTimeout = Timeout.apply(5, TimeUnit.SECONDS);

        words
                .mapAsync(5, elem -> ask(ref, elem, askTimeout))
                .map(elem -> (String) elem)
                // continue processing of the replies from the actor
                .map(elem -> elem.toLowerCase())
                .runWith(Sink.ignore(), materializer);

But I cannot find the "import static" directive to make the "ask method" work. I got:

Cannot resolve method ask

What i'm doing wrong? I'm using akka v 2.4 (with Java, no Scala) and following and following step by step the documentation: http://doc.akka.io/docs/akka/2.4/java/stream/stream-integrations.html

Thanks.

Upvotes: 2

Views: 1146

Answers (2)

Woodstock Monkey
Woodstock Monkey

Reputation: 53

This worked for me: import akka.pattern.ask

Upvotes: 1

dfogni
dfogni

Reputation: 798

ask refers to the ask Pattern.

You can use it from java using import static akka.pattern.Patterns.ask

Upvotes: 5

Related Questions