# zbus
**Repository Path**: kofwang/zbus
## Basic Information
- **Project Name**: zbus
- **Description**: Small fast MQ and RPC
- **Primary Language**: Java
- **License**: MIT
- **Default Branch**: master
- **Homepage**: http://zbus.io
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 915
- **Created**: 2018-06-20
- **Last Updated**: 2020-12-20
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
/\\\
\/\\\
\/\\\
/\\\\\\\\\\\ \/\\\ /\\\ /\\\ /\\\\\\\\\\
\///////\\\/ \/\\\\\\\\\ \/\\\ \/\\\ \/\\\//////
/\\\/ \/\\\////\\\ \/\\\ \/\\\ \/\\\\\\\\\\
/\\\/ \/\\\ \/\\\ \/\\\ \/\\\ \////////\\\
/\\\\\\\\\\\ \/\\\\\\\\\ \//\\\\\\\\\ /\\\\\\\\\\
\/////////// \///////// \///////// \////////// QQ Group: 467741880
# ZBUS = MQ + RPC
zbus strives to make Message Queue and Remote Procedure Call fast, light-weighted and easy to build your own service-oriented architecture for many different platforms. Simply put, zbus = mq + rpc.
zbus carefully designed on its protocol and components to embrace KISS(Keep It Simple and Stupid) principle, but in all it delivers power and elasticity.
## Features
- Fast MQ of disk|memory|db, capable of unicast, multicast and broadcast messaging models
- Easy RPC support out of box
- HTTP/WebSocket/InProc + JSON simple format, multiple languages support
- SSL + API Auth secured
- Extremely light-weighted (z---bus)
## Getting started
In zbus-dist directory, just run zbus.bat/sh, JDK8+ required.
Maven
io.zbus
zbus
1.0.0-SNAPSHOT
## MQ Protocol
zbus MQ protocol is pretty simple, just use websocket or http connect to zbus, send out the followsing json format data
### Common format [JSON Key-Value]
{
cmd: pub|sub|create|remove|query|ping //Request required,
status: 200|400|404|403|500 ... //Response required,
body: ,
id: ,
apiKey: ,
signature:
}
All requests to zbus should have id field (optional), when auth required, both apiKey and signature are required.
Signature generation algorithm
1) sort key ascending in request (recursively on both key and value), and generate json string
2) Init HmacSHA256 with secretKey, do encrypt on 1)'s json string to generate bytes
3) signature = Hex format in upper case on the 2)'s bytes
### Publish Message
Request
{
cmd: pub, //required
mq: , //required
body:
}
Response
{
status: 200|400|403|500,
body:
}
### Subscribe Message
Request
{
cmd: sub, //required
mq: , //required
channel: //required
window:
}
Response
First message: indicates subscribe success or failure
{
status: 200|400|403|500,
body:
}
Following messages:
{
mq: , //required
channel: //required
sender:
id:
body:
}
### Take Message
Request
{
cmd: take, //required
mq: , //required
channel: //required
window:
}
Response
{
status: 200|400|403|500|604, //604 stands for NO data
body:
}
### Create MQ/Channel
Request
{
cmd: create, //required
mq: , //required
mqType: memory|disk|db, //default to memory
mqMask: ,
channel: ,
channelMask: ,
offset: ,
checksum:
topic: ,
}
Response
{
status: 200|400|403|500,
body:
}
### Remove MQ/Channel
Request
{
cmd: remove, //required
mq: , //required
channel:
}
Response
{
status: 200|400|403|500,
body:
}
### Query MQ/Channel
Request
{
cmd: query, //required
mq: , //required
channel:
}
Response
{
status: 200|400|403|500,
body:
}
Example
{
body: {
channels: [ ],
mask: 0,
name: "DiskQ",
size: 200000,
type: "disk"
},
status: 200
}
## RPC Protocol
### Request
{
method: , //required
params: [param_array],
module: ,
id: ,
apiKey: ,
signature:
}
### Response
{
status: 200|400|403|500|604 //required
body: ,
id:
}
## Performance
Fast performance test (Apache Benchmark)
Create MQ: http://localhost:15555?cmd=create&mq=MyMQ&mqType=disk
Produce
ab -k -c 32 -n 1000000 http://localhost:15555/?cmd=pub&mq=MyMQ
Create MQ: http://localhost:15555?cmd=create&mq=MyMQ&channel=MyChannel
Consume
ab -k -c 32 -n 1000000 http://localhost:15555?cmd=take&mq=MyMQ&channel=MyChannel
Single Mac i7 box with SSD
Produce: ~80,000/s
Consume: ~90,000/s