Protocol Specification
Magic Code: 9 bit, defaultValue:EventMesh Protocol Version: 4 bit, defaultValue:0000 Message Size: 4 bit, the total length of message Header Size: 4 bit,the length of Message Header Message Header: the specific header content of message Message Body: the specific body content of message
The class of Package.java
is message object in business logic layer. It contains two parts: header and body.
public class Package { private Header header; private Object body; } public class Header { private Command cmd; private int code; private String msg; private String seq; }
Message Header(header): The field of Command in Header, used to distinguishing different message types.
Message Body(body): The message body is defined as different objects according to the message type.
Command | type of Body |
---|---|
HEARTBEAT_REQUEST, HEARTBEAT_RESPONSE, HELLO_RESPONSE, CLIENT_GOODBYE_REQUEST, CLIENT_GOODBYE_RESPONSE, SERVER_GOODBYE_REQUEST, SERVER_GOODBYE_RESPONSE, LISTEN_REQUEST, LISTEN_RESPONSE, UNSUBSCRIBE_REQUEST, SUBSCRIBE_RESPONSE, UNSUBSCRIBE_RESPONSE, ASYNC_MESSAGE_TO_SERVER_ACK, BROADCAST_MESSAGE_TO_SERVER_ACK | -- |
HELLO_REQUEST | UserAgent |
SUBSCRIBE_REQUEST | Subscription |
REQUEST_TO_SERVER, REQUEST_TO_CLIENT, RESPONSE_TO_SERVER, RESPONSE_TO_CLIENT, ASYNC_MESSAGE_TO_SERVER, ASYNC_MESSAGE_TO_CLIENT, BROADCAST_MESSAGE_TO_SERVER, BROADCAST_MESSAGE_TO_CLIENT, ASYNC_MESSAGE_TO_CLIENT_ACK, BROADCAST_MESSAGE_TO_CLIENT_ACK, RESPONSE_TO_CLIENT_ACK, REQUEST_TO_CLIENT_ACK | OpenMessage |
REDIRECT_TO_CLIENT | RedirectInfo |
public enum Command { //HeartBeat HEARTBEAT_REQUEST(0), //client send heartbeat request to server HEARTBEAT_RESPONSE(1), //server reply heartbeat response to client //Hello HELLO_REQUEST(2), //client send connect request to server HELLO_RESPONSE(3), //server reply connect response to client //Disconncet CLIENT_GOODBYE_REQUEST(4), //client send disconnect request to server CLIENT_GOODBYE_RESPONSE(5), //server reply disconnect response to client SERVER_GOODBYE_REQUEST(6), //server send disconncet request to client SERVER_GOODBYE_RESPONSE(7), //client reply disconnect response to server //Subscribe and UnSubscribe SUBSCRIBE_REQUEST(8), //client send subscribe request to server SUBSCRIBE_RESPONSE(9), //server reply subscribe response to client UNSUBSCRIBE_REQUEST(10), //client send unsubscribe request to server UNSUBSCRIBE_RESPONSE(11), //server reply unsubscribe response to client //Listen LISTEN_REQUEST(12), //client send listen request to server LISTEN_RESPONSE(13), //server reply listen response to client //send sync message REQUEST_TO_SERVER(14), //client(Producer) send sync msg to server REQUEST_TO_CLIENT(15), //server push sync msg to client(Consumer) REQUEST_TO_CLIENT_ACK(16), //client(Consumer) send ack of sync msg to server RESPONSE_TO_SERVER(17), //client(Consumer) send reply msg to server RESPONSE_TO_CLIENT(18), //server push reply msg to client(Producer) RESPONSE_TO_CLIENT_ACK(19), //client(Producer) send ack of reply msg to server //send async message ASYNC_MESSAGE_TO_SERVER(20), //client send async msg to server ASYNC_MESSAGE_TO_SERVER_ACK(21), //server reply ack of async msg to client ASYNC_MESSAGE_TO_CLIENT(22), //server push async msg to client ASYNC_MESSAGE_TO_CLIENT_ACK(23), //client reply ack of async msg to server //send broadcast message BROADCAST_MESSAGE_TO_SERVER(24), //client send broadcast msg to server BROADCAST_MESSAGE_TO_SERVER_ACK(25), //server reply ack of broadcast msg to client BROADCAST_MESSAGE_TO_CLIENT(26), //server push broadcast msg to client BROADCAST_MESSAGE_TO_CLIENT_ACK(27), //client reply ack of broadcast msg to server //redirect REDIRECT_TO_CLIENT(30), //server send redirect instruction to client }
Scene | Client Send | Server Reply | Remark |
---|---|---|---|
Hello | HELLO_REQUEST | HELLO_RESPONSE | |
Heartbeat | HEARTBEAT_REQUEST | HEARTBEAT_RESPONSE | |
Subscribe | SUBSCRIBE_REQUEST | SUBSCRIBE_RESPONSE | |
Unsubscribe | UNSUBSCRIBE_REQUEST | UNSUBSCRIBE_RESPONSE | |
Listen | LISTEN_REQUEST | LISTEN_RESPONSE | |
Send sync msg | REQUEST_TO_SERVER | RESPONSE_TO_CLIENT | |
Send reply msg of sync msg | RESPONSE_TO_SERVER | -- | |
Send async msg | ASYNC_MESSAGE_TO_SERVER | ASYNC_MESSAGE_TO_SERVER_ACK | |
Send broadcast msg | BROADCAST_MESSAGE_TO_SERVER | BROADCAST_MESSAGE_TO_SERVER_ACK | |
Client start disconnect | CLIENT_GOODBYE_REQUEST | CLIENT_GOODBYE_RESPONSE |
Scene | Server Send | Client Reply | Remark |
---|---|---|---|
Push sync msg to client | REQUEST_TO_CLIENT | REQUEST_TO_CLIENT_ACK | |
Push reply msg of sync msg to client | RESPONSE_TO_CLIENT | RESPONSE_TO_CLIENT_ACK | |
Push async msg to client | ASYNC_MESSAGE_TO_CLIENT | ASYNC_MESSAGE_TO_CLIENT_ACK | |
Push broadcast msg to client | BROADCAST_MESSAGE_TO_CLIENT | BROADCAST_MESSAGE_TO_CLIENT_ACK | |
Server start disconnect | SERVER_GOODBYE_REQUEST | -- | |
Server send redirect | REDIRECT_TO_CLIENT | -- |
The class of LiteMessage.java
is message definition in http protocal of EventMesh-Runtime.If you want to send msg by using http protocol,you can use client in eventmesh-sdk-java, and you just need care the specific protocol in the field of content.
public class LiteMessage { private String bizSeqNo; private String uniqueId; private String topic; private String content; private Map<String, String> prop; private long createTime = System.currentTimeMillis(); }
Request Method: POST
Message Composition: RequestHeader + RequestBody
RequestHeader
Key | Description |
---|---|
Env | Enviroment of Client |
Region | Region of Client |
Idc | IDC of Client |
Dcn | DCN of Client |
Sys | Subsystem ID of Client |
Pid | Client Process ID |
Ip | Client Ip |
Username | Client username |
Passwd | Client password |
Version | Protocol version |
Language | Develop language |
Code | Request Code |
RequestBody
Key | Description |
---|---|
clientType | Producer:clientType is ClientType.PUB,Consumer:clientType is ClientType.SUB |
heartbeatEntities | Heartbeat content,contains topic,url... |
RequestHeader
same with RequestHeader of heartbeat msg
RequestBody
Key | Description |
---|---|
topic | topic of client want to subscribe |
url | url of client, server push msg to the url when receiving msg from other components |
RequestHeader
same with RequestHeader of Heartbeat Msg
RequestBody
same with RequestBody of Subscribe Msg
RequestHeader
same with RequestHeader of Heartbeat Msg
RequestBody
Key | Description |
---|---|
topic | topic of msg |
content | msg content |
ttl | timeout time of msg |
bizSeqNo | biz sequence number of msg |
uniqueId | unique mark of msg |
Scene | Client Send | Server Reply | Remark |
---|---|---|---|
Heartbeat | HEARTBEAT(203) | SUCCESS(0)/EVENTMESH_HEARTBEAT_ERROR(19) | |
Subscribe | SUBSCRIBE(206) | SUCCESS(0)/EVENTMESH_SUBSCRIBE_ERROR(17) | |
Unsubscribe | UNSUBSCRIBE(207) | SUCCESS(0)/EVENTMESH_UNSUBSCRIBE_ERROR(18) | |
Send async msg | MSG_SEND_ASYNC(104) | SUCCESS(0)/EVENTMESH_SEND_ASYNC_MSG_ERR(14) |
Scene | Server Send | Client Reply | Remark |
---|---|---|---|
Push async msg to client | HTTP_PUSH_CLIENT_ASYNC(105) | retCode | retCode=0,send success |