Kitchensync-core

KitchenSync-core - A Java Library for Distributed Communication


Project maintained by mrstampy Hosted on GitHub Pages — Theme by mattgraham

A Java Library for Distributed Communication

KitchenSync on Google+

Quickstart

Release 2.3.6 - September 3, 2014

Release 2.3.5 - September 2, 2014

Release 2.3.4 - August 31, 2014

Release 2.3.3 - August 30, 2014

Release 2.3.2 - August 25, 2014

Release 2.3.1 - August 23, 2014

Release 2.2.3 - August 17, 2014

Release 2.2.2 - August 14, 2014

Release 2.2.1 - August 12, 2014

Release 2.1 - August 10, 2014

Release 2.0 - August 2, 2014

KitchenSync Architecture

KitchenSync-core is a Java Library for non-centralized network communication between separate processes using the UDP protocol. Channels can be created as multicast channels which allow broadcasting of messages to all connected channels, port-specific channels or next-port-available channels and are intended to be easily created and destroyed as required. It is built on top of Netty and is designed to be simple to understand and use while providing the ability to customise individual channels.

Two interfaces - KiSyChannel and KiSyMulticastChannel - provide the API for network communication. Three abstract implementations - AbstractKiSyChannel, AbstractPortSpecificKiSyChannel, and AbstractKiSyMulticastChannel - exist for ease of channel creation:

public class ByteArrayChannel extends
        AbstractKiSyChannel<ByteArrayByteBufCreator, ByteArrayMessageInitializer, NioDatagramChannel> {

    @Override
    protected ByteArrayMessageInitializer initializer() {
        return new ByteArrayMessageInitializer();
    }

    @Override
    protected Class<NioDatagramChannel> getChannelClass() {
        return NioDatagramChannel.class;
    }

    @Override
    protected ByteArrayByteBufCreator initByteBufCreator() {
        return new ByteArrayByteBufCreator();
    }

}

The ChannelInitializer is a Netty class which is used to initialise a Bootstrap object for the channel and is ignored if the Bootstrap already exists. Netty channel handlers are added to the channel's pipeline in the implementation of the ChannelInitializer to control the channel's behaviour such as using SSL for connections:

@Override
protected void initChannel(DatagramChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();

    pipeline.addLast(new SslHandler(context.createSSLEngine()));
    pipeline.addLast(new KiSyMessageHandler());
}

KiSyChannels can send and receive one of two types of messages by default - byte arrays and strings.

Inbound and Outbound

KitchenSync-core adds to the Netty architecture - which provides the ability to add custom handlers to interface with applications - by providing inbound and outbound message managers which are initialised on application startup to apply inbound and outbound application specific KitchenSync handler implementations to messages. This separates channel configuration (in the ChannelInitializer) from message processing such as logging of messages, persistence of messages, autonomous event triggering on message, etc. The handlers' execution is ordered to allow sequential operations to take place. Note that the handlers exist for preparation of messages for processing by the application and execution of any presend logic. Any significant processing of the message should be done on a separate thread. Strictly speaking only one implementation is necessary - inbound, to pull messages into the application.