使用Openfire,Smack和Play的聊天网站的架构!(Architecture for a chat website using Openfire, Smack and Play! Frame

编程入门 行业动态 更新时间:2024-10-27 07:23:36
使用Openfire,Smack和Play的聊天网站的架构!(Architecture for a chat website using Openfire, Smack and Play! Framework)

我正在开发一个使用Openfire XMPP服务器的聊天网站,客户端使用Smack API。 使用Smack API的Web项目是使用Play实现的! 框架使它RESTful。 我选择了Play! 因为它的异步编程产品(Comet Sockets / WebSockets)。

基本上,到目前为止,我的架构如下所示:

Openfire < - > Webserver < - >用户/浏览器。

为了支持Android设备,并最大限度地重用代码,我是否应该将XMPP客户端代码实现为网站和Android客户端常见的RESTful Web服务?

Openfire < - > Webservice < - >网站< - >浏览器/用户。

Openfire < - > Webservice < - > Android App。

我害怕可扩展性问题,因为引入了中间Web服务? 由于必须经历多个组件,我是否会在通信中引入延迟?

对上述任何建议都会有所帮助。 谢谢。

I am developing a chat website that makes use of the Openfire XMPP server, with the client side using Smack API. The web project that makes use of the Smack API is implemented using the Play! framework making it RESTful. I chose Play! because of its Asynchronous Programming offerings (Comet Sockets/WebSockets).

Basically, my architecture, so far, is like below:

Openfire <-> Webserver <-> User/Browser.

In order to support Android devices too, and to maximize code-reuse, should I implement the XMPP client side code as a RESTful webservice that is common for both the web site and the Android clients?

Openfire <-> Webservice <-> Website <-> Browser/User.

Openfire <-> Webservice <-> Android App.

I'm afraid of scalability issues, because of the introduction of an intermediate web service? Would I be introducing latency in the communication as a result of having to go through multiple components?

Any advice on the above would be helpful. Thanks.

最满意答案

可伸缩性的关键是解耦。 因此,从本质上讲,您可以根据“如果其中一个组件发生故障,其他组件是否会继续正常工作?”来解决问题。 除了避免世界末日场景之外,您还可以独立地水平扩展每个组件。

考虑到这一点,现在让我们继续讨论您的具体用例。 层的层次仍然让我看到一些关于Java EE架构的噩梦。 它不仅会引入不必要的延迟,还会使查明问题变得更加困难。 如果您的服务失败,是由Web服务器,Android应用程序还是Web服务导致的失败?

如果要重用代码,请重用代码而不是复制组件。 这就是图书馆的用途。 将您的公共代码作为库提取并在Web服务器和Android应用程序中使用它。

The key to scalability is decoupling. So in an essence you can think of the problem in terms of "If one of the components fail, will the other components continue to work normally?". In addition to avoiding end of the world scenarios you can also independently scale horizontally each component.

With that in mind lets now move on to your specific use case. Layers for the sake of layers are what still make me see nightmares about some Java EE architectures around. Not only does it introduce unnecessary latency, it also makes it harder to pinpoint a problem. If your service fails, was the failure caused by the web server, android application or the web service?

If you want code reuse, reuse code instead of duplicating components. That`s what libraries are for. Take your common code and extract as a library and use it in both the web server and Android application.

更多推荐

本文发布于:2023-07-19 20:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1186693.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:架构   聊天网站   Smack   Play   Openfire

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!