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

Dev Services for Infinispan

Quarkusは、Dev Servicesと呼ばれる機能をサポートしており、設定なしで様々なデータソースを作成することができます。Dockerを実行していて、 quarkus.infinispan-client.hosts を設定していない場合、Quarkusはテストや開発モードの実行時に自動的にInfinispanコンテナを起動し、自動的に接続を設定します。

Infinispan Dev Servicesをカスタマイズするために、以下のプロパティが用意されています:

ビルド時に固定される設定プロパティ - その他の設定プロパティは実行時にオーバーライド可能です。

Configuration property

デフォルト

If DevServices has been explicitly enabled or disabled. DevServices is generally enabled by default, unless there is an existing configuration present.

When DevServices is enabled Quarkus will attempt to automatically configure and start a database when running in Dev or Test mode and when Docker is running.

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_ENABLED

Show more

boolean

true

Optional fixed port the dev service will listen to.

If not defined, the port will be chosen randomly.

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_PORT

Show more

int

Indicates if the Infinispan server managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. If a matching container is found, it is used, and so a second one is not started. Otherwise, Dev Services for Infinispan starts a new container.

The discovery uses the quarkus-dev-service-infinispan label. The value is configured using the service-name property.

Container sharing is only used in dev mode.

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_SHARED

Show more

boolean

true

The value of the quarkus-dev-service-infinispan label attached to the started container. This property is used when shared is set to true. In this case, before starting a container, Dev Services for Infinispan looks for a container with the quarkus-dev-service-infinispan label set to the configured value. If found, it will use this container instead of starting a new one. Otherwise, it starts a new container with the quarkus-dev-service-infinispan label set to the specified value.

This property is used when you need multiple shared Infinispan servers.

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_SERVICE_NAME

Show more

string

infinispan

The image to use. Note that only official Infinispan images are supported.

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_IMAGE_NAME

Show more

string

List of the artifacts to automatically download and add to the Infinispan server libraries.

For example a Maven coordinate (org.postgresql:postgresql:42.3.1) or a dependency location url.

If an invalid value is passed, the Infinispan server will throw an error when trying to start.

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_ARTIFACTS

Show more

list of string

Add a site name to start the Infinispan Server Container with Cross Site Replication enabled (ex. lon). Cross Site Replication is the capability to connect two separate Infinispan Server Clusters that might run in different Data Centers, and configure backup caches to copy the data across the clusters with active-active or active-passive replication. See more about Cross Site Replication in the Infinispan Documentation https://infinispan.org/docs/stable/titles/xsite/xsite.html Configure mcast-port to avoid forming a cluster with any other running Infinispan Server container.

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_SITE

Show more

string

If you are running an Infinispan Server already in docker, if the containers use the same mcastPort they will form a cluster. Set a different mcastPort to create a separate cluster in Docker (e. 46656). A common use case in a local Docker development mode, is the need of having two different Infinispan Clusters with Cross Site Replication enabled. see https://github.com/infinispan/infinispan-simple-tutorials/blob/main/infinispan-remote/cross-site-replication/docker-compose/

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_MCAST_PORT

Show more

int

Runs the Infinispan Server container with tracing enabled. Traces are disabled by default

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_TRACING_ENABLED

Show more

boolean

false

Sets Infinispan Server otlp endpoint. Default value is http://localhost:4317

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_TRACING_EXPORTER_OTLP_ENDPOINT

Show more

string

http://localhost:4317

Infinispan Server configuration chunks to be passed to the container.

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_CONFIG_FILES

Show more

list of string

Environment variables that are passed to the container.

Environment variable: QUARKUS_INFINISPAN_CLIENT_DEVSERVICES_CONTAINER_ENV

Show more

Map<String,String>

If DevServices has been explicitly enabled or disabled. DevServices is generally enabled by default, unless there is an existing configuration present.

When DevServices is enabled Quarkus will attempt to automatically configure and start a database when running in Dev or Test mode and when Docker is running.

Environment variable: QUARKUS_INFINISPAN_CLIENT__NAMED_INFINISPAN_CLIENTS__DEVSERVICES_ENABLED

Show more

boolean

true

Optional fixed port the dev service will listen to.

If not defined, the port will be chosen randomly.

Environment variable: QUARKUS_INFINISPAN_CLIENT__NAMED_INFINISPAN_CLIENTS__DEVSERVICES_PORT

Show more

int

Indicates if the Infinispan server managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. If a matching container is found, it is used, and so a second one is not started. Otherwise, Dev Services for Infinispan starts a new container.

The discovery uses the quarkus-dev-service-infinispan label. The value is configured using the service-name property.

Container sharing is only used in dev mode.

Environment variable: QUARKUS_INFINISPAN_CLIENT__NAMED_INFINISPAN_CLIENTS__DEVSERVICES_SHARED

Show more

boolean

true

The value of the quarkus-dev-service-infinispan label attached to the started container. This property is used when shared is set to true. In this case, before starting a container, Dev Services for Infinispan looks for a container with the quarkus-dev-service-infinispan label set to the configured value. If found, it will use this container instead of starting a new one. Otherwise, it starts a new container with the quarkus-dev-service-infinispan label set to the specified value.

This property is used when you need multiple shared Infinispan servers.

Environment variable: QUARKUS_INFINISPAN_CLIENT__NAMED_INFINISPAN_CLIENTS__DEVSERVICES_SERVICE_NAME

Show more

string

infinispan

The image to use. Note that only official Infinispan images are supported.

Environment variable: QUARKUS_INFINISPAN_CLIENT__NAMED_INFINISPAN_CLIENTS__DEVSERVICES_IMAGE_NAME

Show more

string

List of the artifacts to automatically download and add to the Infinispan server libraries.

For example a Maven coordinate (org.postgresql:postgresql:42.3.1) or a dependency location url.

If an invalid value is passed, the Infinispan server will throw an error when trying to start.

Environment variable: QUARKUS_INFINISPAN_CLIENT__NAMED_INFINISPAN_CLIENTS__DEVSERVICES_ARTIFACTS

Show more

list of string

Add a site name to start the Infinispan Server Container with Cross Site Replication enabled (ex. lon). Cross Site Replication is the capability to connect two separate Infinispan Server Clusters that might run in different Data Centers, and configure backup caches to copy the data across the clusters with active-active or active-passive replication. See more about Cross Site Replication in the Infinispan Documentation https://infinispan.org/docs/stable/titles/xsite/xsite.html Configure mcast-port to avoid forming a cluster with any other running Infinispan Server container.

Environment variable: QUARKUS_INFINISPAN_CLIENT__NAMED_INFINISPAN_CLIENTS__DEVSERVICES_SITE

Show more

string

If you are running an Infinispan Server already in docker, if the containers use the same mcastPort they will form a cluster. Set a different mcastPort to create a separate cluster in Docker (e. 46656). A common use case in a local Docker development mode, is the need of having two different Infinispan Clusters with Cross Site Replication enabled. see https://github.com/infinispan/infinispan-simple-tutorials/blob/main/infinispan-remote/cross-site-replication/docker-compose/

Environment variable: QUARKUS_INFINISPAN_CLIENT__NAMED_INFINISPAN_CLIENTS__DEVSERVICES_MCAST_PORT

Show more

int

Runs the Infinispan Server container with tracing enabled. Traces are disabled by default

Environment variable: QUARKUS_INFINISPAN_CLIENT__NAMED_INFINISPAN_CLIENTS__DEVSERVICES_TRACING_ENABLED

Show more

boolean

false

Sets Infinispan Server otlp endpoint. Default value is http://localhost:4317

Environment variable: QUARKUS_INFINISPAN_CLIENT__NAMED_INFINISPAN_CLIENTS__DEVSERVICES_TRACING_EXPORTER_OTLP_ENDPOINT

Show more

string

http://localhost:4317

Environment variables that are passed to the container.

Environment variable: QUARKUS_INFINISPAN_CLIENT__NAMED_INFINISPAN_CLIENTS__DEVSERVICES_CONTAINER_ENV

Show more

Map<String,String>

Infinispan Server configuration chunks to be passed to the container.

Environment variable: QUARKUS_INFINISPAN_CLIENT__NAMED_INFINISPAN_CLIENTS__DEVSERVICES_CONFIG_FILES

Show more

list of string

アプリケーションの実稼働バージョンを実行する場合、Infinispan接続は通常通り設定する必要があります。本番データベース設定を application.properties に含め、Dev Servicesを引き続き使用したい場合は、 %prod. プロファイルを使用してInfinispanの設定を定義することをお勧めします。

Dev Services for Infinispanは、サーバーの起動をDockerに依存しています。

実行中のInfinispan Serverへの接続

devモードでは何も設定する必要はありません。 サーバーはランダムなポートで実行されます。固定ポートが必要な場合は、 quarkus.infinispan-client.devservices.port プロパティを設定してください。

実行中のInfinispan Serverは認証が有効で、フル管理者ロールを持つユーザーがいます。このユーザーのクレデンシャルは admin/password です。

Infinispan Server Consoleへのアクセス

Infinispan Serverには、ブラウザでアクセスできるWebコンソールが用意されています:

  1. Dev UI を開く

  2. Infinispan Client のボックスが表示されます。 Web Console をクリックし、上記のクレデンシャルを入力します。

Dev UI Infinispan

Dockerに対応していない環境では、Infinispan Serverを手動で立ち上げるか、既に稼働しているサーバーに接続する必要があります。

Infinispanサーバーイメージのオーバーライド

エクステンションは定期的に更新され、Dev ServicesはInfinispanの最新の最終版イメージを起動します。ニーズに合った別のイメージを指定するには、 quarkus.infinispan-client.devservices.image-name プロパティを使用してください。

Infinispanの開発サービスの有効化/無効化

Infinispanの開発サービスは、以下の条件が満たされない限り自動的に有効になります:

  • quarkus.infinispan-client.devservices.enabledfalse に設定されている

  • quarkus.infinispan-client.hosts が設定されている

Infinispan 開発サービスはブローカーの起動に Docker を利用しています。 お使いの環境が Docker をサポートしていない場合、ブローカーを手動で起動するか、すでに起動しているブローカーに接続する必要があります。 ブローカーのアドレスは quarkus.infinispan-client.server-list を使用して設定できます。

実行中のサーバーへの設定の提供

Dev Services for Infinispanは、デフォルトでinfinispan.xmlファイルを使用してInfinispanをスピンアップします。 しかし、サーバーに追加の設定を提供すると便利な場合があります。 この場合、xml、yaml、またはjson形式の設定ファイルをリソースのクラスパスに追加し、以下の設定を行います:

quarkus.infinispan-client.devservices.config-files=server-config-override.xml (1)
1 server-config-override.xmlは、resourcesフォルダの下にあるファイルです
<infinispan> (1)
    <cache-container>
        <local-cache name="my-local-cache"> (2)
            <encoding media-type="application/x-protostream" />
        </local-cache>
    </cache-container>
</infinispan>
1 server-config-override.xml ファイルの内容
2 キャッシュ設定を指定することで、このキャッシュがサーバー・コンテナ上に存在することになります。

Cross Site Replication

Cross Site Replication構成でInfinispan Serverコンテナを実行する場合、サイト名を指定する必要があります。

quarkus.infinispan-client.devservices.site=NYC (1)
quarkus.infinispan-client.devservices.mcast-port=46666 (2)
1 Infinispanクラスタのサイト名を提供します。
2 他のコンテナとのクラスタ作成を避けたい場合は、最終的にmcastPortを設定します。

Cross Site Replicationについては、Infinispan Cross Site Replication ドキュメントガイド と Infinispan Cross Site Replication シンプルコードチュートリアル で詳しく説明しています。

名前付き接続のための複数の Dev Services

Infinispan Clientエクステンションは、名前付き接続で複数のInfinispanクラスタへの接続をサポートしています。接続名に対して追加のdevサービスを起動する必要がある場合は、アプリケーションのプロパティで少なくとも1つのプロパティを設定してください:

quarkus.infinispan-client.conn-2.devservices.enabled=true

OpenTelemetryでトレース

Infinispanは、OpenTelemetryによるサーバーのインスツルメンテーションをサポートしています。トレースを有効にするには、 quarkus.infinispan-client.devservices.tracing.enabled を true に設定します。デフォルトの otlpエクスポーターエンドポイントは http://localhost:4317 です。 OpenTelemetryのガイド で説明されているように、コンテナでJaegerを実行している場合、コンテナはデフォルトのネットワークで実行されているため、Infinispanコンテナはlocalhostにアクセスすることができません。以下のコマンドでIPを取得し、 quarkus.infinispan-client.devservices.tracing.exporter.otlp.endpoint プロパティを設定する必要があります。

docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' jaeger

Infinispan永続化レイヤー

Infinispanのキャッシュは、SQLデータベースにキャッシュを永続化したり、SQLキャッシュストアでデータベースのテーブルやクエリをオフロードするなど、特定のSQLデータベースドライバを使用して永続化レイヤーに接続する必要がある機能をいくつか提供しています。

Infinispan は、アプリケーションが使用するデータベースの種類に応じて、SQL Java Driver を必要とします。特定の SQL ドライバでコンテナをスピンアップするには、 quarkus.infinispan-client.devservices.artifacts を設定します。

永続化とSQL Cache Storesの詳細については、 SQL Store Demo + Quarkus DemoInfinispan Persistence Documentation ガイドをご覧ください。

共有サーバー

ほとんどの場合、アプリケーション間でサーバーを共有する必要があります。Dev Services for Infinispanは、 dev モードで動作する複数のQuarkusアプリケーションが1つのサーバーを共有できるように、 サービス検出 メカニズムを実装しています。

Dev Services for Infinispanは、コンテナを識別するためのラベル( infinispan )を付けてコンテナを起動します。

複数の(共有)サーバーが必要な場合は、 quarkus.infinispan-client.devservices.service-name 属性を設定し、サーバー名を指定することができます。同じ値を持つコンテナを探し、見つからない場合は新しいコンテナを起動します。デフォルトのサービス名は、 infinispan です。

共有は、devモードではデフォルトで有効ですが、testモードでは無効です。 quarkus.infinispan-client.devservices.shared=false で共有を無効にすることが出来ます。

関連コンテンツ