我正在试验 akka
,并且(按照文档),我有以下代码:
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);
但是我找不到使“ask 方法”工作的“import static”指令。 我得到了:
Cannot resolve method ask
我做错了什么?我正在使用 akka v 2.4(使用 Java,没有 Scala)并逐步遵循文档: http://doc.akka.io/docs/akka/2.4/java/stream/stream-integrations.html
谢谢。
最佳答案
ask
指的是 ask Pattern。
您可以使用 import static akka.pattern.Patterns.ask
从 java 中使用它
关于java - 无法解决方法问题 - Akka Streaming with Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43614722/