wsky / top-push

Message-push abstraction component, provide useful messaging components.
8 stars 4 forks source link

no message buffer throw exception or drop message directly? #23

Closed wsky closed 11 years ago

wsky commented 11 years ago

Top push server hold fixed buffer area, if no buffer to use, return NoMessageBufferException.

server is design to handle c10K+ clients, max flush 1000 messages once per client for balance.

state builder idle time and client how busy affect message RETAIN time

https://github.com/wsky/top-push/blob/master/src/main/java/com/tmall/top/push/PushManager.java#L171

https://github.com/wsky/top-push/blob/master/src/main/java/com/tmall/top/push/PushManager.java#L209

private void rebuildClientsState(Client client, boolean noPending,
            boolean pending, boolean offline) {
        if (noPending && pending && !offline) {
            this.pendingClients.add(client);
            this.idleClients.remove(client.getId());
            this.offlineClients.remove(client.getId());
            if (this.stateHandler != null)
                this.stateHandler.onClientPending(client);
        } else if (!pending && !offline) {
            this.idleClients.put(client.getId(), client);
            this.offlineClients.remove(client.getId());
            if (this.stateHandler != null)
                this.stateHandler.onClientIdle(client);
        } else if (offline) {
            // TODO:clear pending messages of offline client after
            // a long time
            this.offlineClients.put(client.getId(), client);
            this.idleClients.remove(client.getId());
            if (this.stateHandler != null)
                this.stateHandler.onClientOffline(client);
        }
    }
wsky commented 11 years ago

improvement: