コンソールから、スキーマを追加、表示、および設定できます。また、レジストリーに無効なコンテンツが追加されないようにするルールを作成することもできます。
curl -X POST -H "Content-type: application/json; artifactType=AVRO" \
-H "X-Registry-ArtifactId: prices-value" \
--data '{
"type":"record",
"name":"price",
"namespace":"com.redhat",
"fields":[{"name":"symbol","type":"string"},
{"name":"price","type":"string"}]
}'
https://my-cluster-service-registry-myproject.example.com/api/artifacts -s
curl -X POST -H "Content-type: application/json; artifactType=AVRO" \
-H "X-Registry-ArtifactId: prices-value" \
--data '{
1
"type":"record",
"name":"price",
"namespace":"com.redhat",
"fields":[{"name":"symbol","type":"string"},
{"name":"price","type":"string"}]
}'
https://my-cluster-service-registry-myproject.example.com/api/artifacts -s
2
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
<plugin>
<groupId>io.apicurio</groupId>
<artifactId>apicurio-registry-maven-plugin</artifactId>
<version>${registry.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>register</goal>
</goals>
<configuration>
<registryUrl>https://my-cluster-service-registry-myproject.example.com/api</registryUrl>
<artifactType>AVRO</artifactType>
<artifacts>
<schema1>${project.basedir}/schemas/schema1.avsc</schema1>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.apicurio</groupId>
<artifactId>apicurio-registry-maven-plugin</artifactId>
<version>${registry.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>register</goal>
</goals>
<configuration>
<registryUrl>https://my-cluster-service-registry-myproject.example.com/api</registryUrl>
<artifactType>AVRO</artifactType>
<artifacts>
<schema1>${project.basedir}/schemas/schema1.avsc</schema1>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
String registryUrl_node1 = PropertiesUtil.property(clientProperties, "registry.url.node1",
"https://my-cluster-service-registry-myproject.example.com/api");
try (RegistryService service = RegistryClient.create(registryUrl_node1)) {
String artifactId = ApplicationImpl.INPUT_TOPIC + "-value";
try {
service.getArtifactMetaData(artifactId);
} catch (WebApplicationException e) {
CompletionStage <ArtifactMetaData> csa = service.createArtifact(
ArtifactType.AVRO,
artifactId,
new ByteArrayInputStream(LogInput.SCHEMA$.toString().getBytes())
);
csa.toCompletableFuture().get();
}
}
String registryUrl_node1 = PropertiesUtil.property(clientProperties, "registry.url.node1",
1
"https://my-cluster-service-registry-myproject.example.com/api");
try (RegistryService service = RegistryClient.create(registryUrl_node1)) {
String artifactId = ApplicationImpl.INPUT_TOPIC + "-value";
try {
service.getArtifactMetaData(artifactId);
2
} catch (WebApplicationException e) {
CompletionStage <ArtifactMetaData> csa = service.createArtifact(
ArtifactType.AVRO,
artifactId,
new ByteArrayInputStream(LogInput.SCHEMA$.toString().getBytes())
);
csa.toCompletableFuture().get();
}
}
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow