提供您自己的错误处理逻辑

错误消息经常会要求您采取操作来解决消息正文中指示的问题。要简化日常的同步管理,您可选择添加您自己的逻辑,以在发出特定的错误消息时自动执行这些操作。

过程

  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
    #                          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 (_)
    #
    # 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=Doefirstname=John),每个参数集用空格隔开。

    要执行的操作必须是对有效例程或程序的引用。

例如,假设您想包括一个用户出口,用来在每次发出消息 DSYD000E 时通过寻呼机通知您。可以编写一个名为 pager.exe 的程序,它会呼叫您的寻呼机,并包括寻呼号作为参数。DSYUserExits 文件中的该行可能类似如下所示:

DSYD000E=pager.exe number=9980674

还可随命令包括下列参数和变量:

ID
使用此参数来写消息号。对于参数值,指定变量 DSYID

MSG
使用此参数来编写消息文本。对于参数值,指定 DSYMSG 来编写实际的消息文本,或者指定 DSYMSG_ 来编写消息文本,但应将文本中的所有空格转换为下划线字符。

以下示例将对同一寻呼机拨号,但是要同时提交消息号及其文本作为参数,因此,在寻呼机窗口中它们看起来将会如下所示:

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

Sync Server 不检查 DSYUserExits 属性文件中的条目的有效性,也不会验证与消息相关联的操作是否已完成。

使用 DSYUserExitsTest.bat 文件工具来测试用户出口例程。使用以下格式来进行测试:

DSYUserExitsTest.bat dsy_message_id

其中,dsy_message_id 是要模拟的消息号。如果不提供消息标识,则会显示可用的消息标识的列表。

具有消息标识 DSYS001I 的示例命令:

DSYUserExitsTest.bat dsys001i

生成了 DSYS001I 消息,并且启动了为此消息号定义的用户出口。

具有无效消息号的示例命令:

DSYUserExitsTest.bat zzz

DSYUserExitsTest 工具的输出是:

DSYUserExitsTest
找不到 DSY 消息标识“ZZZ”。有效的 DSY 消息标识是:
DSYA000E、DSYA001E、DSYD000E、DSYD002E、DSYD006E 和 DSYD007E ...

相关概念

相关任务