マイクロサービスを実行
最終更新日時: 2026/10/27マイクロサービスとしてビルドしたジョブやルートは、スタンドアロンモードではTalend Studioから独立して実行できます。マイクロサービスとしてビルドされたSOAPサービスは、fat .jarファイルからも実行できます。
プロジェクトからビルドされたマイクロサービスに対してデフォルトアプリケーションプロパティを設定するには、で設定を編集します。ファイルは、プロジェクトからビルドされた各マイクロサービスに適用されます。設定の環境設定キーは、ms_standalone_application_propertiesです。
マイクロサービスの.jarファイルを実行する場合は、コンソールウィンドウで次の操作を行います:
-
マイクロサービスの.jarファイルがあるディレクトリーに切り替えます。
-
次のコマンドを入力します。
java -jar <ArchiveFileName> --context=<context_environment_name> --configuration.additional-location=<configuration_file_path> --<context_parameter_name>=<context_parameter_value>
デフォルトでは、マイクロサービスの実行中に、そのマイクロサービス Jar内の/configフォルダーにある設定ファイルを呼び出す設定になっています。configuration.additional-locationプロパティを使えば、設定ファイルがある外部の設定フォルダーに切り替えることができます。
たとえば次のコマンドは、マイクロサービスJarがあるディレクトリーにあるcustom.propertiesファイルの設定ファイルを使い、DemoREST_0.1.jarという名前のマイクロサービスを実行します。
java -jar DemoREST_0.1.jar --configuration.additional-location=./custom.properties次のパラメーターはプロパティファイルで設定できます。例:
# ============================================================================
# Microservice runtime configuration (application.properties)
#
# Applicability of each parameter:
# [ALL] - applies to all microservices (REST and SOAP)
# [REST] - applies to REST microservices only
# [SOAP] - applies to SOAP microservices only
# ============================================================================
# [ALL] Location of the startup banner printed in the console.
banner.location=classpath:/config/banner.txt
# --- Embedded HTTP server (Jetty) -------------------------------------------
# [ALL] Protocol (http/https), bind address and listen port of the server.
server.protocol=http
# keep it as 0.0.0.0 for docker container
server.host=0.0.0.0
server.port=8065
# [ALL] Base context path the CXF servlet is mounted on. Both REST (JAX-RS) and
# SOAP (JAX-WS) endpoints are published below this path, e.g.
# http://<host>:<port>/services/<endpoint>.
server.servlet.context-path=/services
# [ALL] Location of the logging (log4j2) configuration file.
logging.config=classpath:config/log4j2.xml
# --- Management / monitoring ------------------------------------------------
# [ALL] Base path and the actuator endpoints exposed for monitoring
# (health, info, metrics, ...).
management.server.base-path=/
management.endpoints.web.exposure.include=info,health,jolokia,prometheus
# [ALL] Expose Java runtime information on the info endpoint.
management.info.java.enabled=true
# [ALL] Default credentials protecting the management endpoints. The same
# credentials are reused for SOAP service security, so SOAP microservices do
# not need their own credentials.
security.user.name=${MS_SECURITY_USER_NAME:#{null}}
security.user.password=${MS_SECURITY_USER_PASSWORD:#{null}}
# [ALL] SSL configuration (disabled by default).
#security.require-ssl=false
#server.ssl.key-store=dispatchJob/src/main/resources/config/keystore.jks
#server.ssl.key-store-type=JKS
#server.ssl.key-store-password=sspass
#server.ssl.key-store-alias=servicekey
#server.ssl.client-auth=need
# [ALL] SSL truststore configuration (disabled by default).
#server.ssl.trust-store=server-truststore.jks
#server.ssl.trust-store-password=password
#server.ssl.trust-store-type=JKS
# [ALL] Embedded Jetty thread pool sizing.
jetty.threadPool.maxThreads=200
jetty.threadPool.minThreads=8
#jetty.threadPool.threadNamePrefix=JettyThread
# [ALL] Server access (request) log settings (disabled by default).
#server.requestlog.enabled=false
#server.requestlog.append=true
#server.requestlog.file=request.log
#server.requestlog.retaindays=1
#server.requestlog.format=%{client}a - %u %t "%r" %s %O "%{Referer}i" "%{User-Agent}i"
# --- SOAP (JAX-WS) specific -------------------------------------------------
# [SOAP] Parameters below are reserved for SOAP microservices. They share the
# same HTTP server and base path as REST (server.servlet.context-path above);
# SOAP endpoints are published as <context-path>/<service>?wsdl. SOAP service
# security reuses the shared security.user.* credentials defined above. The
# entries are documented for the SOAP microservice build and are commented out
# (no effect until the build consumes them).
# [SOAP] Publish the WSDL and the CXF service-list page under the base path.
#soap.wsdl.publish=true
#soap.service-list.hide=falseさらにmanagement.endpoints.secured=true/falseパラメーターを使えば、healthエンドポイントとinfoエンドポイントの基本認証を有効または無効にできます。 この操作は、jolokiaエンドポイントの基本認証には影響しません。
ルートマイクロサービスの場合:
-
http://localhost:8065/healthを使用することで、デフォルトのチェックやカスタムチェックを含む、マイクロサービスの稼働状況チェックのステータスを取得できます。Camelコンテキストは常にデフォルトのチェック項目となります。
-
http://localhost:8065/readyを使用することで、デフォルトのチェックやカスタムチェックを含む、マイクロサービスの準備状況チェックのステータスを取得できます。ルート内のすべてのフローには、デフォルトで準備状況チェッカーが備わっています。
info.app.encoding=UTF-8
info.app.java.source=17
info.app.java.target=17management.endpoint.prometheus.enabled=true/falseパラメーターを使用して、マイクロサービスのPrometheusエンドポイントを有効または無効にすることができます。
security.enabled=[true/false]
security.type=[BASIC/JWT]
security.jwt.keystore.type=[JKS/PKCS12/JWKS]
security.jwt.keystore.url=
security.jwt.keystore.file=
security.jwt.keystore.password=
security.jwt.keystore.alias=
security.jwt.audience=プロパティファイルでのBASICおよびJWTベアラートークンタイプのセキュリティ設定、およびとPrometheusエンドポイントの有効化は、マイクロサービスの実行時に、コマンドラインで関連するパラメータを使うことで上書きできます。
マイクロサービス設定(application.properties)のコンテキストパラメーターは、すべてオーバーライドできます。コンテキストパラメーターの優先順位については、次のように後者が前者をオーバーライドします:
- マイクロサービスアーカイブのデフォルトコンテキスト。
- --context=<context_environment_name>
- --config.additional-location=anyFile1,anyFile2
- anyFile1
- anyFile2
- --ctxParamName=ctxParamValue --ctxParamName=ctxOtherParamValue
--ctxParam2Name=ctxParam2Value
この例では、2番目のctxParamNameパラメーターが最初のパラメーターをオーバーライドします。結果は次のようになります:
ctxParamName=ctxOtherParamValue and ctxParam2Name=ctxParam2Value
マイクロサービスを.zipファイルとして実行するためには、次の操作を行います:
-
任意のディレクトリーで.zipファイルを展開します。
-
<ArchiveFileName>フォルダーに移動します。ここには、外部のconfigフォルダー、マイクロサービスの.jarファイル、開始スクリプトが含まれています。このフォルダーで、Linux (.sh)およびWindows (.bat)用のマイクロサービスを開始します。
-
configフォルダー内の設定ファイルを必要に応じて編集し、Linux上では.shファイル、Windows上では.batファイルを実行し、外部設定でマイクロサービスを開始します。