[英]Akka how to connect source, flow, and sink
I have created a source, flow and a sink我已经创建了一个源、流和一个接收器
The source is an integer source源是 integer 源
The flow transfers the integer to string流程将 integer 转移到字符串
and the sink writes to a file并且接收器写入文件
But I don't know how to connect all of them together to get a runnable graph但我不知道如何将所有这些连接在一起以获得可运行的图表
public static void main(String[] args) {
ActorSystem system = ActorSystem.create();
Materializer materializer = ActorMaterializer.create(system);
Source<Integer, NotUsed> source = Source.range(0, 100);
Flow<Integer, ByteString, NotUsed> flow = Flow.fromFunction((i) -> {
return ByteString.fromString(i.toString());
});
Sink<ByteString, CompletionStage<IOResult>> sink = FileIO.toPath(Paths.get("love.txt"));
}
I focus your wording "runnable graph".我关注你的措辞“可运行图”。 Please look at https://doc.akka.io/docs/akka/current/stream/stream-graphs.html#constructing-graphs with care of taking java for your programming language at the left side for the correct code samples.请查看https://doc.akka.io/docs/akka/current/stream/stream-graphs.html#constructing-graphs ,注意左侧的 Z93F725A07423FE1C8846F448B33D21F 代码示例的正确代码示例。 On this page is a runnable graph sample code, which should help you to connect your streaming elements together.此页面上有一个可运行的图形示例代码,它可以帮助您将流媒体元素连接在一起。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.