-
Notifications
You must be signed in to change notification settings - Fork 116
RexPro Messages
Communication over RexPro is achieved by sending and receiving messages that adhere to the format specified on this page. There are several clients that communicate via RexPro that would serve as good examples for how communication over RexPro works:
- Rexster Console
- RexsterClient – A Java language binding
- rexpro-python – A Python languge binding
Evern RexPro message consists of the following segments:
[protocol version][message type][message size][message body]
segment | type(bytes) | description |
---|---|---|
protocol version | byte(1) | The version of RexPro. Currently, this value should be set to zero. |
message type | byte(1) | The type of message as described below. |
message size | int(4) | The length of the message body |
message body | byte(n) | The body of the message itself containing the instructions for the RexPro Server. This portion of the message is serialized using MsgPack. |
RexPro messages are divided into those that deal with requests made from the client and those that involved a response from the server. The following table represents an overview of the basic message set:
message | type | description |
---|---|---|
session | request | A request to open or close the session with the RexPro Server. |
session | response | The response from the RexPro Server to a session request containing session information. |
script | request | A request to process a Gremlin script on the RexPro Server. |
script | response | A response to a script request. Script response messages actually refer to a set of response messages that are unique to each serialization channel (i.e. MsgPack, GraphSON, and Console). |
error | response | A response from the RexPro Server indicating a problem has occurred. |
NOTE – The following sections describe the individual RexPro Messages in greater detail. It is important to note that the messages are defined in terms of MsgPack serialization, so data types defined must adhere to MsgPack expectations.
The request class of messages are those that are sent by the client to the RexPro Server for processing.
The Session Request Message is used to establish or destroy a session on the RexPro Server. When a session is opened, future Script Request Messages can be executed within this session and variable bindings established in previous scripts can be accessed.
Map<String, Object> Meta
byte[] Session
byte[] Request
byte Channel
String Username
String Password
Meta attributes:
graphName: (String) not required, the name of the graph to open a session on
graphObjName: (String) not required, the variable name of the graph object, defaults to 'g'
killSession: (Boolean) not required, if true, the given session will be destroyed, otherwise, one will be created, defaults to false
The Script Request Message is used to send Gremlin scripts to the RexPro Server. Script Requests can be made either in-session or sessionless. In-session requires that a session is already established with the RexPro Server via the Session Request Message. Sessionless Script Request Messages can be sent without the context of the session but come with the limitation that variable bindings established by a script are lost between requests.
```text
Map<String, Object> Meta
byte[] Session
byte[] Request
String LanguageName
String Script
byte[] Bindings
Meta attributes:
inSession: (Boolean) not required, indicates this requests should be executed in the supplied session, defaults to false
isolate: (Boolean) not required prevents variables defined in this request from being accessible in later requests, defaults to true
transaction: (Boolean) not required executes script within a transaction, committing if successful, rolling back if not. Has no effect with non transactional graph. defaults to true
graphName: (String) not required, the name of the graph to open a session on
graphObjName: (String) not required, the variable name of the graph object, defaults to 'g'
*note: supplying graphName or graphObjName for a session request which already has these values defined will raise an exception
The response class of messages are those that are sent by the RexPro Server back to the client, in response to a request message.
The Session Response Message is used to send a response to a Session Request Message and is sent when the session is successfully created. The Session Response Message will contain information about the session like:
- Session Identifier – Used on future Script Request Messages that need to be made on the session.
- Languages – The list of Gremlin flavors that are [[configured|Rexster Configuration] for Rexster. By default the language list will just be
gremlin-groovy
.
Map<String, Object> Meta
byte[] Session
byte[] Request
String[] Languages
Meta attributes:
None
A Script Response Message contains the results of a Gremlin script sent in a Script Request Message.
ConsoleScriptResponse
Map<String, Object> Meta
byte[] Session
byte[] Request
String[] ConsoleLines
byte[] Bindings
Meta attributes:
None
MsgPackScriptResponse
Map<String, Object> Meta
byte[] Session
byte[] Request
byte[] Results;
byte[] Bindings;
Meta attributes:
None
An Error Response Message may be returned by the RexPro Server for any request message sent.
Map<String, Object> Meta
byte[] Session
byte[] Request
String ErrorMessage
Meta attributes:
flag: (Integer) error reason {INVALID_MESSAGE:0, INVALID_SESSION:1, SCRIPT_FAILURE:2, AUTH_FAILURE:3}