Dev Services for Pulsar
借助 Quarkus Messaging Pulsar 扩展(quarkus-messaging-pulsar
),针对 Pulsar 的 Dev Services 会在开发模式和运行测试时自动启动一个 Pulsar 代理。因此,你无需手动启动代理。应用程序会自动配置。
With Quarkus Messaging Pulsar extension (quarkus-messaging-pulsar
)
Dev Services for Pulsar automatically starts a Pulsar broker in dev mode and when running tests.
So, you don’t have to start a broker manually.
The application is configured automatically.
Enabling / Disabling Dev Services for Pulsar
除非满足以下条件,否则会自动启用针对 Pulsar 的 Dev Services:
Dev Services for Pulsar is automatically enabled unless:
-
quarkus.pulsar.devservices.enabled
is set tofalse
-
the
pulsar.client.serviceUrl
is configured -
all the Reactive Messaging Pulsar channels have the
serviceUrl
attribute set
用于 Pulsar 的 Dev Services 依赖于 Docker 来启动代理。如果您的环境不支持 Docker,您将需要手动启动代理或连接到已运行的代理。您可以使用 pulsar.client.
配置代理地址。
Dev Services for Pulsar relies on Docker to start the broker.
If your environment does not support Docker, you will need to start the broker manually, or connect to an already running broker.
You can configure the broker address using pulsar.client.
.
Shared broker
大多数情况下,您需要在应用程序之间共享代理。用于 Pulsar 的 Dev Services 为在 dev 模式下运行您的多个 Quarkus 应用程序实施了一个 service discovery 机制,以共享一个代理。
Most of the time you need to share the broker between applications. Dev Services for Pulsar implements a service discovery mechanism for your multiple Quarkus applications running in dev mode to share a single broker.
用于 Pulsar 的 Dev Services 使用 |
Dev Services for Pulsar starts the container with the |
如果您需要多个(共享)代理,您可以配置 quarkus.pulsar.devservices.service-name
属性并指出代理名称。它会寻找具有相同值的一个容器,或者如果找不到容器,则会启动一个新容器。默认服务名称是 pulsar
。
If you need multiple (shared) brokers, you can configure the quarkus.pulsar.devservices.service-name
attribute and indicate the broker 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 pulsar
.
在 dev 模式下默认启用共享,但在测试模式下禁用共享。您可以使用 quarkus.pulsar.devservices.shared=false
禁用共享。
Sharing is enabled by default in dev mode, but disabled in test mode.
You can disable the sharing with quarkus.pulsar.devservices.shared=false
.
Setting the port
默认情况下,用于 Pulsar 的 Dev Services 会选择一个随机端口并配置应用程序。您可以通过配置 quarkus.pulsar.devservices.port
属性来设置端口。
By default, Dev Services for Pulsar picks a random port and configures the application.
You can set the port by configuring the quarkus.pulsar.devservices.port
property.
请注意,Pulsar 通告地址会使用所选端口自动配置。
Note that the Pulsar advertised address is automatically configured with the chosen port.
Configuring the image
用于 Pulsar 的 Dev Services 支持 official Apache Pulsar image。
Dev Services for Pulsar supports the official Apache Pulsar image.
可以配置自定义镜像名称,如下所示:
A custom image name can be configured as such:
quarkus.pulsar.devservices.image-name=datastax/lunastreaming-all:2.10_4.7
Configuring the Pulsar broker
您可以使用自定义代理配置配置用于 Pulsar 的 Dev Services。
You can configure the Dev Services for Pulsar with custom broker configuration.
下面的示例启用事务支持:
The following example enables transaction support:
quarkus.pulsar.devservices.broker-config.transaction-coordinator-enabled=true
quarkus.pulsar.devservices.broker-config.system-topic-enabled=true