Handy and efficient alternative to Netty, Apache Mina, and other similar solutions for high performance networking. A tiny abstraction layer on top of
Eventloop and Java NIO Adapters for
AsyncTcpSocket along with
- Support of
Promisesfor read and write operations
- Compatibility with
ChannelConsumerAsyncTcpSocket can work as a CSP channel with built-in back pressure propagation, and can be plugged into
Datastreampipeline with all its features (like buffering, compression, serialization/deserialization, data transformations, data filtering, reducing, etc.)
- Extensively optimized and has almost no performance overhead, uses
A fully asynchronous
TCP socket with TLS support. Allows sending/receiving data to/from the network. Can be used as a building block for creating custom TCP servers/clients
or implementing custom networking protocols. Socket has an extremely simple and intuitive API that consists of
CSP module can be used to wrap socket into
There is also an asynchronous
UDP socket for UDP communications.
AbstractServer class serves as a foundation for building Eventloop-aware TCP servers (HTTP servers, RPC servers, TCP file services, etc.):
- Support of start/stop semantics
WorkerServerinterface, so all subclasses of
AbstractServercan be readily used as worker servers
- Support of
PrimaryServer implementation which works in primary Eventloops as a balancer. It takes external “accept” requests and redistributes them to the WorkerServers that will then execute the actual “accept” requests in their corresponding worker Eventloop threads.
To run the examples, you need to clone ActiveJ from GitHub
And import it as a Maven project. Check out tag v4.3. Before running the examples, build the project.
These examples are located at
In this example we are using an implementation of
SimpleServer which receives a message and sends a response (
PONG). We will also use
AsyncTcpSocketNio as a client to send 3 request messages (
A simple TCP console client which connects to TCP server:
It sends characters, receives some data back through CSP channel, parses it and then prints out to console.
Simple TCP echo server which runs in an eventloop:
This server listens for connections and when client connects, it parses its message and sends it back as CSP channel via socket.
This image illustrates communication and transformations between TCP client and server that use Datastream for data processing.
This server represents
Server from the above illustration: