Having exception committing offset in pubsublite

83 Views Asked by At

The whole document doesn't give me clear example how to use the API to commit/list offsets

Here is the code I tried to run

        CursorServiceClient csc =
            CursorServiceClient.create(
                    CursorServiceSettings.newBuilder().setEndpoint(CursorServiceSettings.getDefaultEndpoint()).build()
            );
    CursorClient cc = new CursorClientImpl(CloudRegion.of("us-west1"), csc);
    ApiFuture<Map<Partition, Offset>> af = cc.listPartitionCursors(SubscriptionPath.newBuilder()
            .setName(SubscriptionName.of("TestSubsciption"))
            .setLocation(CloudRegion.of("us-west1"))
            .setProject(ProjectNumber.of(1111111111l)).build());
    af.get();

It returns an error page Error 404 (Not Found)!!1

The requested URL /google.cloud.pubsublite.v1.CursorService/ListPartitionCursors was not found on this server. That’s all we know.

1

There are 1 best solutions below

0
On

Pub/Sub Lite uses exclusively regional endpoints, not the global ones. That being said, manually committing offsets should not usually be done- instead you should use the Pub/Sub compatible clients for subscribing as shown in the samples.

If you really, really want to manually commit and list offsets, file a FR on the GitHub repo and we can prioritize adding a manual offset commit wrapper with better UX.