The English version of quarkus.io is the official project site. Translated sites are community supported on a best-effort basis.

Apicurio注册表的开发服务

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 their 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

启用/禁用Apicurio注册表的开发服务

Apicurio注册表的开发服务是自动启用的,除非:

  • quarkus.apicurio-registry.devservices.enabled 设为 false

  • mp.messaging.connector.smallrye-kafka.apicurio.registry.url 已配置

  • mp.messaging.connector.smallrye-kafka.schema.registry.url 已配置

  • 所有响应式消息Kafka通道都设置了 apicurio.registry.url 属性或 schema.registry.url 属性

Apicurio注册表的开发服务依赖于Docker来启动注册表。如果你的环境不支持Docker,你需要手动启动注册表,或者使用一个已运行的注册表。在这种情况下,你可以使用一个属性为SmallRye响应式消息中的所有Kafka通道配置注册表的URL。对于Apicurio Registry serde来说,就是:

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

对于Confluent Schema Registry serde来说,就是:

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

共享的注册表

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 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

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

设置端口

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

注意,SmallRye响应式消息中的Kafka通道会自动使用所选的端口进行配置。

配置镜像

Apicurio注册表的开发服务使用 apicurio/apicurio-registry-mem 镜像. 你可以从 https://hub.docker.com/r/apicurio/apicurio-registry-mem 中选择任何一个2.x版本:

quarkus.apicurio-registry.devservices.image-name=quay.io/apicurio/apicurio-registry-mem:2.6.13.Final

Compose

The Apicurio Dev Services supports Compose Dev Services. It relies on a compose-devservices.yml, such as:

name: <application name>
services:
  apicurio:
    image: quay.io/apicurio/apicurio-registry-mem:2.6.13.Final
    ports:
      - "8080"

Related content