独自のエラー処理ロジックの作成

ほとんどの場合、エラー・メッセージは、メッセージ・テキストに示された問題を解決するために処置を行うように要求します。 日常の同期管理を単純化するために、特定のエラー・メッセージ が発行されたときに、これらの処置を自動的に実行する独自のロジックを追加することができます。

手順

  1. エラーの自動処理を定義するには、任意のテキスト・エディターを使用して、次のファイルを編集のためにオープンします。
    DSYUserExits.properties
    

    このファイルは、メッセージ番号がログに書き込まれるときに実行される ルーチンまたはプログラムとメッセージ番号を関連付けます。このプロパティー・ファイルは、 多くのさまざまなパラメーターをサポートします。

    # Formats:
    # {DSY message id}={class to execute} {environment parameters}
    # {DSY message id}={command to execute} {environment parameters}
    #   where
    #     {DSY message id}:
    #       a DSY* message id that you want to define a user exit for (such as
    #       DSYD000E)
    #     {class to execute}:
    #       the name the Java .class to execute. This class must implement the
    #       com.ibm.mobileservices.DSYUserExitsInterface
    #     {command to execute}:
    #       the name the command to execute (such as pager.exe)
    #     {environment parameters}:
    #       a series of parameters to pass in to the class or command to execute
    #
    #   Optional command tags:
    #     <DSYID>            = the message id
    #     <DSYIDMSG>         = the message id message text
    #     <DSYIDMSG_>        = the message id message text, but all blanks are
    #                          converted to underscores
    #     <DSYMSG>           = the message text
    #     <DSYMSG_>          = the message text, but all blanks are converted to
    #                          underscores.
    #     <SERVER_IPADDRESS> = the server ip address (such as 9.112.19.143)
    #     <SERVER_NAME>      = the server name (such as mpauser.stl.ibm.com)
    #
    # Refer to the messages section for available DSY message ids.
    #
    # Example 1:
    #   If you wanted to have user exists for DSYD000E, you would add a line
    #   similar to the following:
    #
    # DSYD000E=pager.exe number=5551234 id=<DSYID> msg=<DSYMSG_>
    #
    # When a DSYD000E message was issued, the pager.exe command would be executed
    # with two environment parameters would be set: number=5551234, id=DSYD000E
    # and msg=DSY message text, substituting an underscore (_) for blanks.
    #
    # Example 2:
    #   If you wanted to have a class executed when a DSYD020E was encountered,
    #   you would add a line similar to the following:
    #
    # DSYD020E=com.ibm.mobileservices.DSYUserExitsSample.class
    #
    # When a DSYD020E was issued, the com.ibm.mobileservices.DSYUserExitsSample
    # class would be executed.
    
  2. ファイルの最後で、そのメッセージがログに書き込まれる際に、メッセージ番号と実行される処置を 組み合わせます。 処置は、 コマンド (実行可能ファイルまたはバッチ・ファイルなど) または Java クラスにすることができます。 次の形式を使用します。
    message_number=action parameter=value
    
    上の形式で、

    message_number
    メッセージの番号。メッセージ番号およびそれに関連付けられているテキストに ついては、エラー・メッセージを参照してください。

    action
    呼び出されたコマンドまたは Java クラスを参照するファイル。Java クラスは 、com.ibm.mobileservices.DSYUserExitsInterface をインプリメントする必要があります。

    parameter=value
    一連のパラメーター・セット (lastname=Doe firstname=John など) であり、 各セットはスペースによって区切られます。

    実行される処置は、有効なルーチンまたはプログラムを指していなければなりません。

例えば、メッセージ DSYD000E が発行されたときに、 ページ表示を行うユーザー出口を組み込むと仮定します。ページャーにダイヤルする pager.exe と呼ばれるプログラムを作成し、ページャー番号をパラメーターとして指定できます。 DSYUserExits ファイルにおける行は次のようになります。

DSYD000E=pager.exe number=9980674

コマンドで次のパラメーターおよび変数を指定することもできます。

ID
このパラメーターを使用して、メッセージの番号を書き込みます。 パラメーター値については、変数 DSYID を指定します。

MSG
このパラメーターを使用して、メッセージ・テキストの書き込みを行います。 パラメーター値については、DSYMSG を指定して実際のメッセージ・テキスト を書き込むか、DSYMSG_ を使用してメッセージ・テキストを書き込みますが、 テキストにおけるすべてのブランク・スペースは下線文字に変換します。

次の例は同一のページャーにダイヤルしますが、メッセージ番号およびそのテキストが 「Pager (ページャー)」ウィンドウに表示されるように、それらの両方をパラメーターと してサブミットします。

DSYD000E=pager.exe number=9980674 id=dsyid msg=dsymsg

同期サーバーは、DSYUserExits プロパティー・ファイルの項目の妥当性のチェックを行わず、 メッセージに関連付けられた処置が完了したかどうかもチェックしません。

ユーザー出口ルーチンをテストするには、DSYUserExitsTest.bat ファイル・ツールを使用します。以下の形式を使用してテストします。

DSYUserExitsTest.bat dsy_message_id

ここで、dsy_message_id は、シミュレートするメッセージ番号です。メッセージ ID を指定しなければ、使用可能なメッセージ ID のリストが表示されます。

メッセージ ID が DSYS001I のコマンド例は次のとおりです。

DSYUserExitsTest.bat dsys001i

DSYS001I メッセージが生成され、このメッセージ番号に定義されているユーザー出口 が開始されます。

以下は、無効なメッセージ番号を指定したコマンド例です。

DSYUserExitsTest.bat zzz

DSYUserExitsTest ツールの出力は、以下のようになります。

DSYUserExitsTest
    DSY message id 'ZZZ' not found. Valid DSY message id's are: 
DSYA000E, DSYA001E, DSYD000E, DSYD002E, DSYD006E, DSYD007E, ...

関連した概念

関連したタスク