22. April 2008

Simple Remote Procedure Call - Batch

SRPC-Batch is an extension to SRPC. The batch-mode carries multiple remote procedure calls in a single transaction. The global "Method" indicates the batch mode. Individual RPCs are prefixed by an index, e.g. "1:Method=...".

Example:

  1. C: Method=Batch
  2. C: 0:Method=GetQuote
  3. C: 0:Symbol=GOOG
  4. C: 1:Method=GetQuote
  5. C: 1:Symbol=APPL
  1. S: Status=1
  2. S: 0:Status=1
  3. S: 0:Average=123
  4. S: 0:Low=121
  5. S: 0:High=125
  6. S: 1:Status=1
  7. S: 1:Average=456
  8. S: 1:Low=455
  9. S: 1:High=457

Rationale:

In rare cases clients want to execute not just one, but multiple commands. This saves network bandwidth and roundtrip time, especially on SSL connections. It also allows a batch of RPCs to be executed consecutively. We are using batch commands also to store them in the database and execute multiple commands on request.

Details:

  • the request has a "Method=Batch",
  • the request contains multiple remote procedure calls,
  • parameters of individual RPCs are prefixed by an index N and a colon: "N:", e.g. "1:",
  • the index indicates individual RPCs,
  • all parameters of an individual RPC have the same index,
  • the index starts with "0" (zero),
  • each RPC has a "Method" parameter (1:Method=...),
  • meta parameters as usual: "1:Symbol/Encoding=cstring",
  • the response has a "Status=..." (0/1) indicating success of the batch-parser,
  • the response carries a "Status" for each individual request,
  • result parameters use the same syntax as the requests (1:Status=...),
  • RPC results have the the same index as the corresponding request,
  • the receiver executes ALL commands and returns their result even if some fail.

Comments:

  • the batch-extension is optional. It is not required for receivers. Better ask your server if it is supported,
  • in additon to "Method", the request may have additional "global" parameters.

Kommentar veröffentlichen