gitmyhub

mpush

Java ★ 3.8k updated 4y ago

MPush开源实时消息推送系统

An open-source Java server for pushing real-time notifications directly to mobile devices over persistent connections, so your backend can send messages to any phone instantly without polling. Includes client SDKs for Android, iOS, and Java.

JavaNettyZooKeeperRedissetup: hardcomplexity 4/5

MPush is an open-source real-time push notification system written in Java, designed to deliver messages from a server to mobile devices reliably and quickly. The problem it solves is a common one in mobile app development: standard HTTP connections close after each request, so there is no efficient way for a server to proactively send a message to a phone. MPush maintains persistent TCP connections with each client device, keeping those connections alive with heartbeats, so that the server can push a message to any connected device at any time with very low latency.

The server component uses a Java networking library called Netty to handle large numbers of simultaneous connections efficiently. It depends on two external services: ZooKeeper, which handles service coordination when running multiple server nodes together, and Redis, which handles session storage and message queuing. The configuration is written in a format called HOCON and covers network ports, connection timeouts, heartbeat intervals, compression thresholds, and traffic shaping settings. RSA and AES encryption are built in to secure the connection between the server and each client.

The project is organized as a set of related repositories. The main server lives here. A separate scheduler component (alloc) decides which server node to assign each connecting client to. A personalized push center (mpns) handles rules for targeting specific users. Client SDKs are available for Android (with a demo app), iOS in both Swift and Objective-C, and plain Java. This means an app team can run their own push infrastructure rather than relying on a third-party service.

To get started, you install a JDK (version 1.8 or higher), ZooKeeper, and Redis, then download a release package and edit the configuration file before starting the server with a shell script. Detailed setup documentation and examples are linked from the repository page.

Where it fits