Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Java中将元素发送到Source.actorRef或Source.queue_Java_Akka_Akka Stream_Akka Http - Fatal编程技术网

如何在Java中将元素发送到Source.actorRef或Source.queue

如何在Java中将元素发送到Source.actorRef或Source.queue,java,akka,akka-stream,akka-http,Java,Akka,Akka Stream,Akka Http,我目前正在为一个个人项目与Akka Streams(Java)合作,我很难理解如何将元素发送到源代码 其想法是使用WebSocket将内容推送到用户的web浏览器中。我已经按照Akka HTTP文档使用Akka Streams创建了一个请求-响应系统,但这不是我想要做的 查看Akka Streams文档,我看到有Source.queue和Source.actorRef。但我不明白如何将元素放入源代码中Source.queue和Source.actorRef返回一个Source,它没有方法提供(对

我目前正在为一个个人项目与Akka Streams(Java)合作,我很难理解如何将元素发送到
源代码

其想法是使用WebSocket将内容推送到用户的web浏览器中。我已经按照Akka HTTP文档使用Akka Streams创建了一个请求-响应系统,但这不是我想要做的

查看Akka Streams文档,我看到有
Source.queue
Source.actorRef
。但我不明白如何将元素放入
源代码中
Source.queue
Source.actorRef
返回一个
Source
,它没有方法
提供
(对于
Source.queue
)或
tell
(对于
Source.actorRef

我的问题是:如何获得由
Source.ActorRef
创建的
Source
ActorRef
,或使用
Source.queue
创建的
Source
SourceQueueWithComplete
Source
,以便能够将元素发送到我的
Source


我搜索了各种Akka文档,但没有找到这样做的方法。我在互联网上找到的大多数代码都是用Scala编写的,这似乎没有同样的问题。

来自
源的参与者和队列。actorRef
源。队列
分别是这些源中的一个,这意味着只有在流运行时才能获得它们。例如:

final actor ref actor=
Source.actorRef(Integer.MAX_值,OverflowStrategy.fail())
.to(Sink.foreach(m->System.out.println(m)))
.run(物化器);
actor.tell(“做点什么”,ActorRef.noSender());
在Scala中也一样:

implicit val-materializer=actormatarializer()
瓦尔演员=
actorRef(Int.MaxValue,OverflowStrategy.fail)
.to(Sink.foreach(println))
.run()
演员!“做点什么”

akka.io上的相关文档可能与此答案重复。除了此答案之外,您还可以在此处找到相关文档,这些文档可能不太容易找到: