ShampooWoo / linbox_server

LINBOX is a distributed IM system designed for www.medtree.cn.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

linbox_server

LINBOX is a distributed IM system designed for www.medtree.cn.

Download medtree app for iphone at here

Download medtree app for android at here

Tech

  • Netty and tcp protocol
  • Kafka as center MQ
  • Dubbo as rpc framework
  • Zookeeper as config center

Usage

Build the project:

gradle zip

distribution package is under

build/distribution/linbox_server-1.0.zip

Unzip it and start the server:

# start the tcp client:
sh tcpServer.sh

# start the router:
sh consumer.sh

# start the rpc client
sh rpcServer.sh

High availablity and scaliability

Linbox is distributed by design. All of the components of linbox - tcp client, rpc client and router - are all distributed.

Steps to prompt availability:

  • Use zookeeper cluster
  • Use Kafka cluster
  • Use tcp client cluster
  • Use rpc client cluster
    • rpc.xml need to be configured for pointed rpc port, or you can use dynamic ports generated by system.
  • Use router client cluster

Dependencies

Java Version

JDK-1.8 is required to build and run it.

Security Update For JRE

Be carefual: as we use AES-256 encryption, you need to download packages to update your local jre environment.

  • Download package at here
  • Unzip and copy the jars into ${java.home}/jre/lib/security/

Click this for detail information for this problem.

Mysql

Mysql database is used as persistence storage for im messages.

Mysql Versions

There is no special requirement for mysql version. But if you want to use emojis, you need to use mysql version 5.6+, and config the character set to utf8mb4.

Predefined Tables

You can find all mysql operations in package com.linbox.im.server.storage

There are 4 tables predefined in programs, sql script could be find in mysql.sql

Configs

Config mysql connection in im.properties

Redis

Config redis connection in im.properties

Zookeeper

Zookeeper is used as config center of the project. It is also a dependency of dubbo and Kafka. Config Zookeeper in rpc.xml

Kafka

Kafka is used as Center MQ. Kafka is configd in im.properties

Architecture

architecture

Communication Protocol

Linbox use tcp protocal and JSON structure in communication. Data package structure is designed as below:

Version Type Length Content
2 Byte 2 Byte 4 Byte JSON String
Name Description
Version A flag to show the protocol version of the package
Type Request / Response command type
Length The length of the content part
Content Encrypted Data content structured in json

Main Communications

Get history messages

im-pulloldmessage

Get unread count and messages

im-syncunread

Send messages

Im-Communication

About

LINBOX is a distributed IM system designed for www.medtree.cn.


Languages

Language:Java 98.7%Language:Shell 1.3%