Go like channels in Java

huangapple 未分类评论168阅读模式
英文:

Go like channels in Java

问题

我在6年后回到Java,之前一直在使用Go。我正在寻找一些与Go通道在某种程度上相似的模式或库,但是在Java中。

我的目标是创建一种服务,我可以向其中发送事件,并让代码的其他部分进行订阅。

我一直在研究Observables,但似乎你必须在初始时刻就知道所有的值。

英文:

I'm back to Java after 6 years of Go. I'm looking for some pattern or library that is somehow similar to Go channels but in Java.

My objective is to have some kind of service where I can emit events to and have other parts of my code subscribe.

I've been looking at Observables but it seems that you have to know all the values on the initial moment.

答案1

得分: 0

如果你的应用程序是基于Spring的,你可以使用Spring的事件(Events)

否则,可以查看Guava的事件总线(EventBus)

英文:

If your application is Spring-based you can use Spring Events.

Otherwise have a look into Guava's EventBus.

huangapple
  • 本文由 发表于 2023年8月2日 16:55:13
  • 转载请务必保留本文链接:https://java.coder-hub.com/76818178.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定