5

I am new to GCP. I am trying to use Pub/Sub service with schema definition using protobuf.

Schema:

syntax = "proto3";

import "google/protobuf/any.proto";

message Endorsement {
  string endorserId=1;
  google.protobuf.Any data = 2;
  string signature=3;
  bool isVerified=4;
}

message TransactionPayload {
  string policyId =1;
  string txnId =2;
  repeated Endorsement endorsements=3;
}

Validation of this schema fails with an error

Invalid Protocol Buffer schema. Import "google/protobuf/any.proto" has not been loaded.

enter image description here

I need to use google.protobuf.Any, is there any other way to use/define this?

Nitish Bhardwaj
  • 1,113
  • 12
  • 29

1 Answers1

4

Currently, imports are not supported with Pub/Sub's schema support. You'd have to define the message type yourself in the definition for your message type. Note also that the current schema support only allows a single message top-message type to be defined, so you'd also have to embed the Endorsement definition inside the TransactionPayload definition.

Kamal Aboul-Hosn
  • 15,111
  • 1
  • 34
  • 46
  • ohh that's sad. This forces me to move to a different solution for messaging. Thanks for your support. Could you please add some references in the answer pointing to things supported/unsupported by pub/sub at the moment? – Nitish Bhardwaj Jul 12 '21 at 11:12
  • 2
    It turns out this limitation is not mentioned in the documentation yet. Will make sure it is added to https://cloud.google.com/pubsub/docs/schemas. – Kamal Aboul-Hosn Jul 12 '21 at 21:00