Java 中的事件传递库?
我正在寻找一个库,它允许我通过套接字将简单的文本事件从服务器传递到客户端。简单而轻量级的东西。我可以自己写,但决定先检查一下这样的东西是否存在。这个想法是有一个应用程序生成事件(例如订单被拒绝或发生内部错误)并充当服务器。这些事件必须实时传递给所有连接的客户端。客户端只是一个弹出所述事件文本的托盘图标应用程序。一些简单的 UDP 客户端/服务器。有谁知道是否有 Java 库?
谢谢!
I'm looking for a library that will allow me to deliver simple text events from the server to the clients via sockets. Something simple and lightweight. I can write it myself, but decided to check if such thing exists first. The idea is that there's an application that generates events (such as order rejected or an internal error occurred) and acts as a server. Those events must be delivered to all connected clients in real-time. And a client is just a tray-icon app that pop ups the said event's text. Some simple UDP client/server. Does anyone know if there's a library out there for Java?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有很多可能的解决方案,但如果您想要简单,我建议您尝试 Hazelcast
There are many possible solutions, but if you want simple I suggest you try Hazelcast
这可以通过 XMPP pubsub 轻松完成。您可以使用 Smack 连接到您选择的支持 pubsub 的服务器( OpenFire,ejabberd, ...) 因此创建事件的应用程序是发布者,客户端都是订阅者。它将需要使用第 3 方服务器(许多是开源的),但它只是用于所有客户端访问的单个库。我有使用 OpenFire 的经验,大约 15 分钟即可设置完毕。
许多人不会考虑这种轻量级,但实际上没有必要推出自己的 pubsub 解决方案。
This could be easily accomplished with XMPP pubsub. You can use Smack to connect to the server of your choice that supports pubsub (OpenFire, ejabberd, ...) so your application that creates the events is the publisher and the clients are all subscribers. It will require a 3rd party server to be used (many are open source), but it is just a single library for all client access. I have experience with OpenFire and it can be set up in about 15 minutes.
Many will not consider this light weight, but rolling your own pubsub solution is really not necessary.
您应该查看 JBoss Netty 和/或 Apache MINA,这两个都是构建网络协议的框架。尽管您当然可以用它们构建轻量级实现,但您是否认为它们简单是有争议的。
You should check out JBoss Netty and/or Apache MINA, which are both frameworks for building network protocols. It's debatable whether you consider them simple, although you can certainly build lightweight implementations with them.