RPC Server & Client #
While Java applications typically embed Repository and DirectDataOperator directly, polyglot services (Python, Go, Node.js, etc.) and lightweight edge clients that lack direct network access to Kafka, Cassandra, or HBase can interact with Proxima over gRPC.
Proxima ships three modules for RPC communication:
cz.o2.proxima:proxima-server-rpc-proto: Protocol Buffer / gRPC definitions (rpc.proto, Java packagecz.o2.proxima.direct.server.rpc.proto.service) definingIngestServiceandRetrieveService.cz.o2.proxima:proxima-ingest-server-grpc: The gRPC server (cz.o2.proxima.direct.server.IngestServer) wrappingRepositoryandDirectDataOperator.cz.o2.proxima:proxima-ingest-client: High-throughput Java client (cz.o2.proxima.direct.client.IngestClient) with automatic bulk batching, reconnection, and synchronous retrieval helpers.
gRPC Services Overview #
rpc.proto exposes two gRPC services:
IngestService (Writes & Transaction Commits)
#
| RPC Method | Type | Description |
|---|---|---|
ingestBulk(stream IngestBulk) → stream StatusBulk | Bidirectional stream | High-throughput batched ingestion. Responses arrive asynchronously as StatusBulk messages matched by request uuid. |
ingestSingle(stream Ingest) → stream Status | Bidirectional stream | Streaming ingestion for individual Ingest messages. |
ingest(Ingest) → Status | Unary | Synchronous single upsert, delete (delete = true), or wildcard delete (attribute = "prefix.*", delete = true). |
commit(TransactionCommitRequest) → TransactionCommitResponse | Unary | Commits an open RPC transaction (COMMITTED, REJECTED, or FAILED). |
Ingest Status codes: 200 (OK), 400 (Bad Request), 404 (Entity/attribute not found), 412 (Invalid scheme payload), 500 (Internal error), 502 (Bad gateway), 504 (Timeout).
RetrieveService (Reads, Scans & Transaction Begin)
#
| RPC Method | Type | Description |
|---|---|---|
get(GetRequest) → GetResponse | Unary | Fetch a single attribute value and timestamp by (entity, key, attribute). |
listAttributes(ListRequest) → ListResponse | Unary | List wildcard attributes by (entity, key, wildcardPrefix) with optional pagination offset and limit. |
multifetch(MultifetchRequest) → MultifetchResponse | Unary | Execute multiple GetRequest and ListRequest operations in a single round-trip (preserving order). |
begin(BeginTransactionRequest) → BeginTransactionResponse | Unary | Open a new ACID transaction (optionally declaring attributesInvolved) and receive a transactionId. |
scan(ScanRequest) → stream ScanResult | Server stream | Stream a full scan of attributes belonging to the same attribute family. |
Retrieve status codes: 200 (OK), 204 (Already committed transaction), 400 (Bad request), 404 (Not found), 500 (Internal server error).
Starting the RPC Server (IngestServer)
#
IngestServer loads your HOCON configuration, initializes Repository and DirectDataOperator (plus TransactionContext automatically if _transaction is configured), and binds both IngestService and RetrieveService to a gRPC port.
Server Configuration Properties #
| HOCON Key | Default | Description |
|---|---|---|
ingest.server.port | 4001 | TCP port the gRPC server listens on. |
ingest.server.num-threads | 10 * max(2, cores) | Worker thread pool size. |
ingest.ignore-errors | false | Ignore non-fatal initialization errors when loading optional families. |
Launching the Server #
# Load reference.conf / application.conf from classpath
java -cp my-proxima-server.jar cz.o2.proxima.direct.server.IngestServer
# Or specify an explicit HOCON file path
java -cp my-proxima-server.jar cz.o2.proxima.direct.server.IngestServer /etc/proxima/application.conf
Note:
IngestServerhandles gRPC ingestion and retrieval only. RunReplicationControlleras a separate process/deployment to replicate updates from primary commit logs to replica storages and execute transformations.
Using the Java IngestClient
#
Add cz.o2.proxima:proxima-ingest-client to your project. IngestClient automatically batches outgoing Ingest messages over ingestBulk, flushes periodically, tracks in-flight requests by UUID, and retries on transient channel drops:
import com.google.protobuf.ByteString;
import cz.o2.proxima.direct.client.IngestClient;
import cz.o2.proxima.direct.client.Options;
import cz.o2.proxima.direct.server.rpc.proto.service.Rpc;
Options opts = new Options()
.setFlushUsec(100_000) // flush buffered bulk every 100 ms
.setMaxInflightRequests(1000);
try (IngestClient client = IngestClient.create("localhost", 4001, opts)) {
// 1. Asynchronous batched write (upsert)
client.ingest(
"user-1",
"user",
"details",
ByteString.copyFrom(userDetails.toByteArray()),
status -> {
if (status.getStatus() == 200) {
log.info("Ingested successfully (uuid={})", status.getUuid());
} else {
log.error("Ingest failed {}: {}", status.getStatus(), status.getStatusMessage());
}
});
// 2. Delete an attribute
client.delete("user-1", "user", "preferences", status ->
log.info("Delete status: {}", status.getStatus()));
// 3. Synchronous random-access get
Rpc.GetResponse getResp = client.get("user", "user-1", "details");
if (getResp.getStatus() == 200) {
UserDetails details = UserDetails.parseFrom(getResp.getValue());
log.info("Fetched user details: {}", details);
}
// 4. List wildcard attributes
Rpc.ListResponse listResp = client.listAttributes(
Rpc.ListRequest.newBuilder()
.setEntity("user")
.setKey("user-1")
.setWildcardPrefix("event")
.setLimit(20)
.build());
for (Rpc.ListResponse.AttrValue attr : listResp.getValueList()) {
log.info("Attribute {} @ {}", attr.getAttribute(), attr.getStamp());
}
}
Using Raw gRPC Stubs (Java & Python) #
Because the protocol is defined in standard rpc.proto, you can generate clients in any gRPC-supported language (see example/pyclient/ in the repository for a complete Python client).
Python Example #
import uuid
import grpc
import rpc_pb2
import rpc_pb2_grpc
channel = grpc.insecure_channel("localhost:4001")
ingest_stub = rpc_pb2_grpc.IngestServiceStub(channel)
retrieve_stub = rpc_pb2_grpc.RetrieveServiceStub(channel)
# Write an attribute
status = ingest_stub.ingest(
rpc_pb2.Ingest(
uuid=str(uuid.uuid4()),
entity="user",
attribute="details",
key="alice",
value=serialized_user_details_bytes,
)
)
assert status.status == 200
# Read it back
resp = retrieve_stub.get(
rpc_pb2.GetRequest(entity="user", key="alice", attribute="details")
)
if resp.status == 200:
print(f"Found value ({len(resp.value)} bytes) at stamp={resp.stamp}")
ACID Transactions over gRPC #
Clients can execute
ACID transactions remotely across RetrieveService and IngestService:
- Call
RetrieveService.begin(BeginTransactionRequest)to obtain atransactionId. - Perform all reads (
get,listAttributes, ormultifetch) with.setTransactionId(transactionId). The server tracks read keys automatically in the transaction state. - Submit all writes via
IngestService.ingest(...)with.setTransactionId(transactionId)(writes are buffered server-side inTransactionContext). - Finalize with
IngestService.commit(TransactionCommitRequest). If the response status isREJECTED, retry the transaction loop from step 1.