1
我是Akka Streams的新手,我有一个问题。Akka Stream回调
所以我可以从服务器操作和处理数据的一些客户(从下面的官方文档的源代码)。
private static final ActorSystem system = ActorSystem.create("Client");
private static final Materializer materializer = ActorMaterializer.create(system);
final Flow<ByteString, ByteString, CompletionStage<Tcp.OutgoingConnection>> connection =
Tcp.get(system).outgoingConnection("127.0.0.1", 8888);
final Flow<ByteString, ByteString, NotUsed> repl =
Flow.of(ByteString.class)
.map(ByteString::utf8String)
.map(text -> {
System.out.println("Server message ->: " + text);
return ByteString.fromString(text);
});
connection.join(repl).run(materializer);
如何添加回调方法(onComplete()
,onError()
)?
Hello @Martynas。 感谢您的反馈。 我会尽力实施你的建议 –