Dev Services for Apicurio Registry

如果存在诸如 quarkus-apicurio-registry-avroquarkus-confluent-registry-avro 的架构注册表扩展,则适用于 Apicurio 注册表的开发服务将在开发模式下自动启动 Apicurio 注册表实例,并在运行测试时自动启动该实例。同时,SmallRye 响应式消息传递中的所有 Kafka 通道都自动配置为使用此注册表。自动配置仅适用于 Apicurio 注册表 serde 库和 Confluent 架构注册表 serde 库中的序列化程序和反序列化程序,因为已设置其属性:

If an extension for schema registry, such as quarkus-apicurio-registry-avro or quarkus-confluent-registry-avro, is present, Dev Services for Apicurio Registry automatically starts an Apicurio Registry instance in dev mode and when running tests. Also, all Kafka channels in SmallRye Reactive Messaging are automatically configured to use this registry. This automatic configuration only applies to serializers and deserializers from Apicurio Registry serde libraries and Confluent Schema Registry serde libraries, because there properties are set:

# for Apicurio Registry serde
mp.messaging.connector.smallrye-kafka.apicurio.registry.url=http://localhost:8081/apis/registry/v2
# for Confluent Schema Registry serde
mp.messaging.connector.smallrye-kafka.schema.registry.url=http://localhost:8081/apis/ccompat/v6

Enabling / Disabling Dev Services for Apicurio Registry

除非满足以下条件,否则 Apicurio 注册表的开发服务会自动启用:

Dev Services for Apicurio Registry is automatically enabled unless:

  • quarkus.apicurio-registry.devservices.enabled is set to false

  • mp.messaging.connector.smallrye-kafka.apicurio.registry.url is configured

  • mp.messaging.connector.smallrye-kafka.schema.registry.url is configured

  • all the Reactive Messaging Kafka channels have either the apicurio.registry.url attribute or the schema.registry.url attribute set

Apicurio 注册表的开发服务依靠 Docker 来启动注册表。如果您的环境不支持 Docker,则需要手动启动注册表或使用已在运行的注册表。在这种情况下,您可以使用单个属性为 SmallRye 响应式消息传递中的所有 Kafka 通道配置注册表 URL。Apicurio 注册表 serde 为:

Dev Services for Apicurio Registry relies on Docker to start the registry. If your environment does not support Docker, you will need to start the registry manually, or use an already running registry. In such case, you can configure the registry URL for all Kafka channels in SmallRye Reactive Messaging with a single property. For Apicurio Registry serde, that is:

mp.messaging.connector.smallrye-kafka.apicurio.registry.url=... your Apicurio Registry URL...

对于 Confluent 架构注册表 serde,即:

For Confluent Schema Registry serde, that is:

mp.messaging.connector.smallrye-kafka.schema.registry.url=... your Confluent Schema Registry URL...

Shared registry

大多数情况下,你需要在应用程序之间共享注册表。Dev Service for Apicurio Registry 为在 dev 模式下运行的多个 Quarkus 应用程序实现了一个 service discovery 机制,以便共享单个注册表。

Most of the time you need to share the registry between applications. Dev Services for Apicurio Registry implements a service discovery mechanism for your multiple Quarkus applications running in dev mode to share a single registry.

Dev Services for Apicurio Registry 使用 quarkus-dev-service-apicurio-registry 标签启动该容器,该标签用于标识容器。

Dev Services for Apicurio Registry starts the container with the quarkus-dev-service-apicurio-registry label which is used to identify the container.

如果您需要多个(共享)注册表,您可以配置 quarkus.apicurio-registry.devservices.service-name 属性并指示注册表名称。它会查找具有相同值的一个容器,或在找不到任何容器时启动一个新的容器。默认服务名称是 apicurio-registry

If you need multiple (shared) registries, you can configure the quarkus.apicurio-registry.devservices.service-name attribute and indicate the registry name. It looks for a container with the same value, or starts a new one if none can be found. The default service name is apicurio-registry.

在开发模式下,共享功能默认启用,但在测试模式下禁用。您可以使用 quarkus.apicurio-registry.devservices.shared=false 禁用共享。

Sharing is enabled by default in dev mode, but disabled in test mode. You can disable the sharing with quarkus.apicurio-registry.devservices.shared=false.

Setting the port

默认情况下,针对 Apicurio 注册表的 Dev 服务会选择一个随机端口并配置该应用程序。您可以通过配置 quarkus.apicurio-registry.devservices.port 属性来设置端口。

By default, Dev Services for Apicurio Registry picks a random port and configures the application. You can set the port by configuring the quarkus.apicurio-registry.devservices.port property.

请注意,SmallRye Reactive 消息中的 Kafka 频道会自动使用所选端口进行配置。

Note that the Kafka channels in SmallRye Reactive messaging are automatically configured with the chosen port.

Configuring the image

针对 Apicurio 注册表的 Dev 服务使用 apicurio/apicurio-registry-mem 映像。您可以从 [role="bare"][role="bare"]https://hub.docker.com/r/apicurio/apicurio-registry-mem 中选择任何 2.x 版本:

Dev Services for Apicurio Registry uses apicurio/apicurio-registry-mem images. You can select any 2.x version from [role="bare"]https://hub.docker.com/r/apicurio/apicurio-registry-mem:

quarkus.apicurio-registry.devservices.image-name=apicurio/apicurio-registry-mem:latest-snapshot