Use a NIO framework

Issue #10 closed
Julien Herr created an issue

Again, it's a question about the architecture.

Why don't you use a NIO framework like netty, Apache MINA, Grizzly, ...?

Comments (13)

  1. Christian Schudt repo owner

    What would be the benefits? I don't use it because I am not familiar with them and I want to keep this library lighweight. Java's Socket is perfectly fine I think. AFAIK those frameworks are useful for server architectures, which need to handle several thousand connections, but this scenario is unlikely for a client. Also, non-blocking IO would likely increase the complexity.

  2. Julien Herr reporter

    Yes, I understand the lighweight argument.

    And you right about the server needs too. But does it mean it won't be a "good" idea to build a XMPP server or proxy (from/to another protocol by example) with babbler?

    The most benefits I see for this kind of framework is to use non-blocking IO without "complexity". But I'm not enough familiar with them to determine if it could be a good or bad idea (that's why I asked).

    FYI, Async-http-client is a http client which has an netty and grizzly implementation (but right, its main goal is to be async).

  3. Christian Schudt repo owner

    It's not intentend to act as a server or proxy, it's only a client library. Theoretically you could use the xmpp-core project and build your own server/proxy, I guess.

    It has only the "model" classes, which are mapped to XML and which are shared between server and client, e.g. Message, Presence, ...

    The whole business logic needed for a server is not part of this project, though.

  4. Julien Herr reporter

    Ok! If I understand well there is no use case where a "client" will be connected to multiple servers?

  5. Christian Schudt repo owner

    You can do that of course. E.g. Adium client allows for multiple concurrent accounts. But the amount of concurrent sessions is usually only a few, if at all. In this case you can connect each session in its own thread. I can only hardly imagine a client, which wants to manage thousands of concurrent connections to different servers. The connect() and login() methods are blocking methods anyway. Doing this asynchronously would mean a lot of work, a whole new concept and probably also a lot of more complexity to the user of these methods.

  6. Julien Herr reporter

    So, it seems my idea wasn't so good after all! Just a sledge hammer to kill a ant :p

    Thank for you feedback :)

  7. Christian Schudt repo owner

    I told you, maybe one day this issue will be reconsidered.

    After 3 years, that day has finally come!

    Implementing NIO support was a lot of work, but I finally did it: a9ce40d (among many other commits).

    There will be a new connection method using NIO (Netty) starting with version 0.8.0.

  8. Julien HERR

    I'm not playing with xmpp anymore but it's awesome!!! Great job :)

    Did you show perf improvments?

  9. Christian Schudt repo owner

    I didn't do real performance tests. I've created 100 concurrent sessions with blocking and non-blocking IO and stopped the time, but both approaches performed very similar. That doesn't surprise me, afaik NIO doesn't perform faster, it just safes resources (threads).

  10. Log in to comment