Use gRPC with the Java client library

The Java client for Datastore mode offers gRPC as a transport layer option. Using gRPC connection pooling enables distributing RPCs over multiple connections, which can improve performance.

Before you begin

Install the latest version of the google-cloud-datastore library.

How to enable the gRPC transport behavior

To enable the gRPC transport behavior, add setTransportOptions to your client instantiation:

Java
DatastoreOptions datastoreOptions =
       DatastoreOptions.newBuilder()
               .setProjectId("my-project")
               .setDatabaseId("my-database")
               .setTransportOptions(GrpcTransportOptions.newBuilder().build())
               .build();

Setting the transport options explicitly to GrpcTransportOptions configures the client to use gRPC instead of HTTP when making calls to the server.

Deactivate the gRPC transport behavior