SDK コンポーネントおよび操作のトラブルシューティング - Mule 4

以下のトラブルシューティング機能は、Mule SDK 1.4 以降で使用できます。

Java SDK のトラブルシューティングを行うために、ログ記録 (冗長ログを含む) を有効にする方法と、一般的なエラーメッセージの解釈について学習します。

ログ記録

ログを使用して、次の SDK コンポーネントのトラブルシューティングを行います。

コンポーネント名 ログ機能

ソース

ライフサイクルの開始時と終了時など、ソースライフサイクルに関する情報をログに記録します。 エラーと再接続の場合、ログには発生した例外に関連付けられた完全なスタック追跡が表示されます。 クラスター環境の場合、ログにはソース状況情報が表示されます。これは、それがプライマリソースであるかどうかを示します。

ポーリング入力元

ソースによって承認および拒否された項目に関する情報をログに記録します。 拒否の場合、ログには拒否の原因に関する情報が含まれます。

ポーリング入力元のウォーターマーク処理

ポーリング入力元に対するウォーターマーク処理に関する情報をログに記録します。 このプロセスは低レベルのロジックを使用するため、デバッグまたはトラブルシューティングが必要な場合にのみトレースログを有効にします。

プーリング接続プロバイダー

プーリング接続プロバイダーの接続管理に関する情報をログに記録します。 このログには、接続プールの状況情報、およびプールが接続を取得して返すタイミングを示す接続処理が表示されます。

冗長ログ

冗長ログを使用して SDK コンポーネントのトラブルシューティングを行い、状況または動作に関する情報を取得します。 アプリケーションのパフォーマンスに大きく影響するため、冗長ログはテストやトラブルシューティングでのみ使用してください。

Anypoint Studio、または CloudHub API を使用している場合は Anypoint Runtime Manager で、冗長ログを有効にします。 どちらの場合も、アプリケーションのログファイルに情報が記録されます。

Anypoint Studio での冗長ログの有効化

次の手順では、Anypoint Studio を使用して冗長ログを有効にする方法について説明します。

  1. Anypoint Studio にアクセスし、​[Package Explorer]​ ビューに移動します。

  2. アプリケーションのプロジェクト名を開きます。

  3. src/main/resources​ パスフォルダーを開きます。

  4. フォルダー内の ​log4j2.xml​ ファイルを開きます。

    enable-sdk-logging-studio

  5. <Loggers>​ タグ内に ​<AsyncLogger>​ タグを追加します。

    <Loggers>
        ...
        <AsyncLogger name="<component's fully qualified name>" level="<logging level>"/>
        ...
    </Loggers>

    コンポーネントの完全修飾名を指定するための参照として、次の表を使用してください。

    名前 完全修飾名 ログレベル

    接続元

    org.mule.runtime.module.extension.internal.runtime.source.ExtensionMessageSource

    DEBUG

    ポーリング入力元

    org.mule.runtime.module.extension.internal.runtime.source.poll.PollingSourceWrapper

    DEBUG

    ポーリング入力元のウォーターマーク処理

    org.mule.runtime.module.extension.internal.runtime.source.poll.PollingSourceWrapper

    TRACE

    プーリング接続プロバイダー

    org.mule.runtime.core.internal.connection.PoolingConnectionHandler​ ​org.mule.runtime.core.internal.connection.PoolingConnectionManagementStrategy

    DEBUG

    次の例は、完全修飾名を ​log4j2.xml​ ファイルに追加し、ソースの冗長ログを有効にする方法を示しています。

    <Loggers>
       ...
        <!-- Mule logger -->
        <AsyncLogger name="org.mule.runtime.core.internal.processor.LoggerMessageProcessor" level="INFO"/>
        <AsyncLogger name="org.mule.runtime.module.extension.internal.runtime.source.ExtensionMessageSource" level="DEBUG"/>
        <AsyncRoot level="INFO">
            <AppenderRef ref="file" />
        </AsyncRoot>
    </Loggers>

Anypoint Runtime Manager での冗長ログの有効化

次の手順では、Anypoint Runtime Manager を使用して冗長ログを有効にする方法について説明します。

  1. Anypoint Runtime Manager にアクセスします。

  2. 目的のアプリケーションを選択します。

  3. 左側のペインで、​[Settings (設定)]​ に移動します。

  4. [Logging (ログ)]​ タブに移動します。

    sdk-verbose-logging-runtime-manager

  5. コンポーネントの完全修飾名とログレベル (DEBUG または TRACE) を追加します。 コンポーネントの完全修飾名を指定する方法が示されている表を参照してください。

  6. [Apply Changes (変更を適用)]​ をクリックします。

ログの例

次の例は、SDK コンポーネントで想定されるログを示しています。

以下の例は、FTP サーバーのファイルをリストする FTP Connector ソースと処理したファイルの名前を記録するロガーで構成される Mule アプリケーションからのログです。

FTP Connector ソースとロガーを表示する Studio の Mule フロー

ソースログの例

次の例は、ソースのログを示しています。

org.mule.runtime.module.extension.internal.runtime.source.ExtensionMessageSource: Message source 'listener' on flow 'ftp-troubleshooting-examples' threw exception. Attempting to reconnect...
org.mule.runtime.module.extension.internal.runtime.source.ExtensionMessageSource: Message source 'listener' on flow 'ftp-troubleshooting-examples' successfully reconnected
org.mule.runtime.module.extension.internal.runtime.source.ExtensionMessageSource: Message source 'listener' on flow 'ftp-troubleshooting-examples' could not be reconnected. Will be shutdown.
org.mule.runtime.module.extension.internal.runtime.source.ExtensionMessageSource: Message source 'listener' on flow 'ftp-troubleshooting-examples' is stopping

ポーリングソースログの例

次の例は、ポーリングソースのログを示しています。

org.mule.runtime.module.extension.internal.runtime.source.poll.PollingSourceWrapper: Item with id:[/ftp-example.json] is accepted
org.mule.runtime.module.extension.internal.runtime.source.poll.PollingSourceWrapper: Item with id:[/ftp-example.json] is rejected with status:[FILTERED_BY_WATERMARK]

ポーリングソースウォーターマークログの例

次の例は、ポーリングソースウォーターマークのログを示しています。

org.mule.runtime.module.extension.internal.runtime.source.poll.PollingSourceWrapper: A new watermark maximum has been found when processing item with id /ftp-example.json for source in flow ftp-troubleshooting-examples

プーリング接続プロバイダーログの例

次の例は、プーリング接続プロバイダーのログを示しています。

org.mule.runtime.core.internal.connection.PoolingConnectionManagementStrategy: Acquiring connection org.mule.extension.ftp.internal.connection.FtpFileSystem@1a0c776f from the pool FTP_Config-5e20b7d9-417d-4307-ab4c-9ef3e7ae4d9b
org.mule.runtime.core.internal.connection.PoolingConnectionManagementStrategy: Status for pool FTP_Config-5e20b7d9-417d-4307-ab4c-9ef3e7ae4d9b: 1 connections are active out of 5 max active limit, 0 connections are idle out of 5 max idle limit

エラー: Cannot Find org.mule.sdk.api Classes (org.mule.sdk.api クラスが見つかりません)

モジュールの親 POM のバージョン 1.4.0 を使用すると、Java SDK によって ​Cannot access XYZ class file: XYZ not found​ または ​Cannot find symbol: method someMethod() location: variable someVar of type XYZ​ (この XYZ は ​org.mule.sdk.api​ パッケージのクラス) などのエラーがスローされます。

<parent>
  <groupId>org.mule.extensions</groupId>
  <artifactId>mule-modules-parent</artifactId>
  <version>1.4.0</version>
</parent>

次に例を示します。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project : Compilation failure:

cannot access org.mule.sdk.api.runtime.streaming.StreamingHelper
[ERROR] class file for org.mule.sdk.api.runtime.streaming.StreamingHelper not found

cannot find symbol
[ERROR]   symbol:   method resolveCursors(java.util.HashMap<java.lang.String,java.lang.Object>,boolean)
[ERROR]   location: variable streamingHelper of type org.mule.runtime.extension.api.runtime.streaming.StreamingHelper

org.mule.sdk.api​ パッケージは実験的機能であり、現在まだ開発中です。非実験的機能のドキュメントページで明示的に指示されない限り、このパッケージは使用しないでください。このパッケージは実験的であるため、MuleSoft ではこのパッケージで定義されたクラスに対するサポート、または後方互換性を保証いたしません。

org.mule.sdk.api​ パッケージのクラスやインターフェースがすべての Mule バージョンで認識されるとは限らない点にも注意が必要です。より正確には、​org.mule.sdk.api​ のどのクラスも Mule バージョン 4.4 以前では認識されず、そのすべてのコンポーネントが Mule 4.4 以降でサポートされるとは限りません。

このエラーを修正するには、​org.mule.sdk.api​ パッケージの使用を避け、代わりに ​org.mule.runtime.extension.api​ パッケージの同等のクラスまたはアノテーションを使用してください。