1

I plan to write a client + server app from scratch myself, one of the main points of the app is chat messaging. I am used to write Rest APIs and I like it. Though in other posts I've read that thats not at all optimal for the 'chat messaging' use case (I agree with that of course).

I'd really like to write the server based on Rest, so my idea (while wanting to have at least some efficiency [not throwing GET requests every second..] and still maintaining somewhat realtime user expirience) basically is:

  • Use some kind of XMPP only for notifying the client, so he would know that the server has something to say to him. (client could then for example call something like "1.2.3.4:5678/.../whatsNew"
  • The server then sends update information (messages, online/offline/not_here statuses etc)

I completly agree that that idea is not pretty and that I should probably use XMPP alone for this, but I think there are some advantages to my approach:

  • As I already know Rest and this app isnt going to be that huge , this might save a lot of time, possibly giving me better chance of finishing this at all.
  • To me Rest seems to be more supported, and basically on every device, browser etc easier to implement
  • Some ports used by XMPP might be blocked (corporate firewalls etc), so, with my approach, if for any reason XMPP doesnt work, my frontend can still make connections and recieve messages, just at worse rate (at refresh or once per 20sec for example if I program it that way)

I'd love to know if I am at least somewhat right.

If its relevant, I plan to write JavaFX frontend (maybe + Maven ( +Spring? )), and Maven + Springboot Java backend.

I think I need XMPP or something similar because I need some realtime features ("user is typing", "user's status is dont_talk_to_me", "message just came:" etc.) and I dont want to spam server with useless requests just to get empty results all the time.

What do you think of that idea using XMPP together with Rest

Thanks very much for any response!

Ondřej
  • 21
  • 5

1 Answers1

0

XMPP sounds like a reasonable choice if you want realtime. Your uncertanties about XMPP aren't completely correct: you can easily use XMPP in browser (either via BOSH, which is HTTP long polling, or with websocket, which should be more efficient) and given that it operates on typical web ports (80/443) it won't get blocked.

There are also many libraries (including for Java: https://xmpp.org/software/libraries.html) that should speed up development process (so you can concetrate on your application).

Otherwise, you would have to develop complete interface layer that would translate what you want into some sort of REST available for user, and it seems that you would still use some sort of persistant connection to get instant notifications.

Wojtek
  • 1,845
  • 1
  • 14
  • 33