Protocol

The sample will be using Simple Binary Encoding generated messages. This allows the sample to focus on the RPC flow, and keep the code simple with limited noise from building zero-copy messages.

Note that while the interaction will appear similar to RPC, it will be stream oriented. To allow outbound requests to be associated with the inbound responses, the protocol includes a correlation field.

Note

SBE Tool generates the message codecs from the XML message definition. For this code to be generated, you will need to run the build. This can be done by cloning the repository, and running gradlew.

Connect Request

The connect request includes the necessary URI and Stream for the server to open a return publication:

1
2
3
4
<sbe:message name="RpcConnectRequest" id="10" description="RPC Sample Connect Request">
    <field name="returnConnectStream" id="1" type="uint16"/>
    <data name="returnConnectUri" id="2" type="varStringEncoding"/>
</sbe:message>

Request

The request method accepts a correlation, which will be returned unmodified in the associated response, plus the parameter toReverse.

1
2
3
4
<sbe:message name="RpcRequestMethod" id="11" description="RPC Sample Request Method">
    <data name="parameters" id="1" type="varStringEncoding"/>
    <data name="correlation" id="2" type="varStringEncoding"/>
</sbe:message>

Response

The request method returns a correlation, along with the reversed result.

1
2
3
4
<sbe:message name="RpcResponseEvent" id="12" description="RPC Sample Response Event">
    <data name="result" id="1" type="varStringEncoding"/>
    <data name="correlation" id="2" type="varStringEncoding"/>
</sbe:message>

The full definition of the messages can be found on GitHub.

Back to top