Architecture for a chat site using Openfire, Smack and Play! Framework

I am developing a chat site that uses the Openfire XMPP server on the client side using the Smack API. A web project using the Smack API is implemented using Play! what makes it restful. I chose Play! because of his suggestions for asynchronous programming (Comet Sockets / WebSockets).

Basically, my architecture still looks like this:

Openfire ↔ Webserver ↔ User / Browser.

In order to support Android devices and maximize code reuse, should I use the client code on the XMPP side as a RESTful web service that is common to both the website and Android clients?

Openfire ↔ Webservice ↔ Website ↔ Browser / User.

Openfire ↔ Webservice ↔ Android app.

Am I afraid of scalability issues due to the implementation of an intermediate web service? Should I introduce latency in a message as a result of going through multiple components?

Any recommendations on the above issue would be helpful. Thanks.

+4
source share
2 answers

The key to scalability is decoupling. Therefore, in essence, you can think of the problem in terms of "If one of the components does not work, will the other components work fine?" In addition, to avoid doomsday scenarios, you can also independently scale each component horizontally.

With that in mind, let's now move on to your specific use case. Layers for layers is what makes me see nightmares around some Java EE architectures. It not only introduces an unnecessary delay, but also makes it difficult to identify a problem. If your service failed, is there a failure caused by the web server, android application or web service?

If you want to reuse the code, use the reuse code instead of duplicating components. This requires libraries. Take your generic code and extract it as a library and use it on both the web server and the Android app.

+4
source

I think it’s best to make a lightweight webpage that consumes the web service directly (like any application) from the browser after it loads.

Thus, the only difference between the application and the webpage is that the webpage will be loaded by the browser every time the user has access to it.

+1
source

Source: https://habr.com/ru/post/1435794/


All Articles