3.4. ブローカーやキューの健全性の確認

AMQ Broker には、ブローカートポロジーのブローカーおよびキューでさまざまなヘルスチェックを実行できるコマンドラインユーティリティーが含まれています。

以下の例は、ユーティリティーを使用してヘルスチェックを実行する方法を示しています。

手順

  1. ブローカートポロジーの特定ブローカー(ノード)に対して実行できるチェックの一覧を参照してください。

    $ <broker_instance_dir>/bin/artemis help check node

    artemis check nodeコマンドで使用できるオプションのセットを説明した出力が表示されます。

    NAME
            artemis check node - Check a node
    
    SYNOPSIS
            artemis check node [--backup] [--clientID <clientID>]
                    [--diskUsage <diskUsage>] [--fail-at-end] [--live]
                    [--memoryUsage <memoryUsage>] [--name <name>] [--password <password>]
                    [--peers <peers>] [--protocol <protocol>] [--silent]
                    [--timeout <timeout>] [--up] [--url <brokerURL>] [--user <user>]
                    [--verbose]
    
    OPTIONS
            --backup
                Check that the node has a backup
    
            --clientID <clientID>
                ClientID to be associated with connection
    
            --diskUsage <diskUsage>
                Disk usage percentage to check or -1 to use the max-disk-usage
    
            --fail-at-end
                If a particular module check fails, continue the rest of the checks
    
            --live
                Check that the node has a live
    
            --memoryUsage <memoryUsage>
                Memory usage percentage to check
    
            --name <name>
                Name of the target to check
    
            --password <password>
                Password used to connect
    
            --peers <peers>
                Number of peers to check
    
            --protocol <protocol>
                Protocol used. Valid values are amqp or core. Default=core.
    
            --silent
                It will disable all the inputs, and it would make a best guess for any required input
    
            --timeout <timeout>
                Time to wait for the check execution, in milliseconds
    
            --up
                Check that the node is started, it is executed by default if there are no other checks
    
            --url <brokerURL>
                URL towards the broker. (default: tcp://localhost:61616)
    
            --user <user>
                User used to connect
    
            --verbose
                Adds more information on the execution
  2. たとえば、ローカルブローカーのディスク使用量がブローカーに設定された最大ディスク使用量を下回ることを確認します。

    $ <broker_instance_dir>/bin/artemis check node --url tcp://localhost:61616 --diskUsage -1
    
    Connection brokerURL = tcp://localhost:61616
    Running NodeCheck
    Checking that the disk usage is less then the max-disk-usage ... success
    Checks run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.065 sec - NodeCheck

    上記の例では、--diskUsage オプションに -1 の値を指定すると、ユーティリティーはブローカーに設定された 最大 ディスク使用量に対してディスクの使用量をチェックすることを意味します。ブローカーの最大ディスク使用量は、broker.xml設定ファイルのmax-disk-usageパラメータを使用して設定されます。max-disk-usage に指定された値は、ブローカーが消費できる利用可能な物理ディスク領域の割合を表します。

  3. ブローカートポロジーの特定キューに対して実行できるチェックの一覧を参照してください。

    $ <broker_instance_dir>/bin/artemis help check queue

    artemis check queueコマンドで、使用できるオプションのセットを説明した出力が表示されます。

    NAME
            artemis check queue - Check a queue
    
    SYNOPSIS
            artemis check queue [--browse <browse>] [--clientID <clientID>]
                    [--consume <consume>] [--fail-at-end] [--name <name>]
                    [--password <password>] [--produce <produce>] [--protocol <protocol>]
                    [--silent] [--timeout <timeout>] [--up] [--url <brokerURL>]
                    [--user <user>] [--verbose]
    
    OPTIONS
            --browse <browse>
                Number of the messages to browse or -1 to check that the queue is
                browsable
    
            --clientID <clientID>
                ClientID to be associated with connection
    
            --consume <consume>
                Number of the messages to consume or -1 to check that the queue is consumable
    
            --fail-at-end
                If a particular module check fails, continue the rest of the checks
    
            --name <name>
                Name of the target to check
    
            --password <password>
                Password used to connect
    
            --produce <produce>
                Number of the messages to produce
    
            --protocol <protocol>
                Protocol used. Valid values are amqp or core. Default=core.
    
            --silent
                It will disable all the inputs, and it would make a best guess for any required input
    
            --timeout <timeout>
                Time to wait for the check execution, in milliseconds
    
            --up
                Check that the queue exists and is not paused, it is executed by default if there are no other checks
    
            --url <brokerURL>
                URL towards the broker. (default: tcp://localhost:61616)
    
            --user <user>
                User used to connect
    
            --verbose
                Adds more information on the execution
  4. このユーティリティーは、1 つのコマンドで複数のオプションを実行できます。たとえば、ローカルブローカーのデフォルトの helloworld キューで、1000 個のメッセージの生成、参照、消費を確認するには、以下のコマンドを使用します。

    $ <broker_instance_dir>/bin/artemis check queue --name helloworld --produce 1000 --browse 1000 --consume 1000
    
    Connection brokerURL = tcp://localhost:61616
    Running QueueCheck
    Checking that a producer can send 1000 messages to the queue helloworld ... success
    Checking that a consumer can browse 1000 messages from the queue helloworld ... success
    Checking that a consumer can consume 1000 messages from the queue helloworld ... success
    Checks run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.882 sec - QueueCheck

    上記の例では、キューチェックの実行時にブローカー URL を指定していないことを確認します。URL を明示的に指定しないと、ユーティリティーはデフォルト値のtcp://localhost:61616を使用します。