Pub/Sub 스키마는 Pub/Sub 메시지에서 데이터 필드 형식을 적용하는 데 사용할 수 있는 선택적 기능입니다.
스키마는 메시지 형식에 대한 게시자와 구독자 간의 계약을 만듭니다. Pub/Sub는 이 형식을 적용합니다.
스키마는 메시지 유형 및 권한을 위한 중앙 권한을 만들어 조직 내 데이터 스트림의 팀 간 소비를 용이하게 합니다. Pub/Sub 메시지 스키마는 메시지의 필드 이름 및 데이터 유형을 정의합니다.
스키마를 만들고 주제와 연결하여 게시된 메시지에 스키마를 적용할 수 있습니다. 특정 메시지가 스키마를 준수하지 않으면 메시지가 게시되지 않습니다. 스키마의 버전을 추가로 만들 수도 있습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[],[],null,["A Pub/Sub schema is an optional feature that you can use to enforce\nthe format of the [data](/pubsub/docs/reference/rpc/google.pubsub.v1#google.pubsub.v1.PubsubMessage.FIELDS.bytes.google.pubsub.v1.PubsubMessage.data) field in a Pub/Sub message.\n\nA schema creates a contract between the publisher and subscriber about the\nformat of the messages. Pub/Sub enforces this format.\nSchemas facilitate inter-team consumption of data streams in your\norganization by creating a central authority for message types and\npermissions. A Pub/Sub message schema defines the names and\ndata types for the fields in a message.\n\nYou can create a schema and associate it with a topic to\nenforce the schema for published messages. If a specific message does\nnot conform to the schema, the message is not published. You can also create\nadditional revisions for a schema.\n\nTypes of schemas\n\nYou can create a schema in Pub/Sub by using one of the\nfollowing frameworks:\n\n- [Apache Avro](https://avro.apache.org/docs/++version++/specification/#schema-declaration)\n- [Protocol Buffer](https://protobuf.dev/)\n\nFor example, the following schema defines the inventory of a warehouse,\nfirst in the Avro format and then in the Protocol Buffer format.\n| **Note:** Avro version 1.11 is supported. For Protocol Buffers, proto2 and proto3 are supported.\n\nApache Avro format \n\n {\n \"type\" : \"record\",\n \"name\" : \"Avro\",\n \"fields\" : [\n {\n \"name\" : \"ProductName\",\n \"type\" : \"string\",\n \"default\": \"\"\n },\n {\n \"name\" : \"SKU\",\n \"type\" : \"int\",\n \"default\": 0\n },\n {\n \"name\" : \"InStock\",\n \"type\" : \"boolean\",\n \"default\": false\n }\n ]\n }\n\n| **Note:** Pub/Sub does not validate the default value of each field, follow the [Apache Avro specification](https://avro.apache.org/docs/1.11.1/specification/) for default value rules.\n\nProtocol Buffer format \n\n syntax = \"proto3\";\n message ProtocolBuffer {\n string product_name = 1;\n int32 SKU = 2;\n bool in_stock = 3;\n }\n\nImportant information about schemas\n\nThe following is some important information regarding creating and\nmanaging Pub/Sub schemas.\n\n- For a schema to work with Pub/Sub, you must define only\n one top-level [type](/pubsub/docs/schemas#types-schema). Import statements that reference other types\n are not supported.\n\n- You can associate the same schema to multiple topics.\n\n- You can manually test whether a message validates against a schema.\n\n- Don't include sensitive information such as personally identifiable\n information (PII) or security data in your schema field names.\n\nQuotas and limits for schemas\n\nSchemas have the following limits:\n\n- The schema definition field cannot exceed 300 KB in size.\n\n- A project can have a maximum of 10,000 schemas.\n\n- A single schema cannot have more than 20 revisions.\n\n For information about schemas and limits related to Pub/Sub,\n see [Pub/Sub quotas and limits](/pubsub/quotas).\n\nWhat's next\n\n- [Create a schema](/pubsub/docs/create-schemas)\n\n- [Associate a schema with a topic](/pubsub/docs/associate-schema-topic)\n\n- [Commit a schema revision](/pubsub/docs/commit-schema-revision)\n\n- [Publish messages to a topic with a schema](/pubsub/docs/publish-topics-schema)"]]