Sun Java System Messaging Server 6 2005Q4 MTA Developer's Reference

Running Your Test Programs

This section describes the tasks that are typically required for running your test programs that enqueue or dequeue messages. The tasks are divided into two groups, those used to run your test programs in a fully functional messaging environment, and those needed if you want to run them manually:

ProcedureTo Run Test Programs in a Messaging Environment

Steps
  1. Add a test channel to the bottom of the imta.cnf file.

    For example:


    (required blank line)
    x_test
    x-test-daemon
  2. Add rewrite rules to the top of the imta.cnf file.

    The following code fragment illustrates this:


    x_test $U%x-test@x-test-daemon
  3. To enable your test channel so that mail can be addressed to user@x_test, recompile your configuration and restart the SMTP server.

    Use the instructions found in the following code example:


    # imsimta cnbuild
    # imsimta restart dispatcher
  4. Create the job_controller.site text file.

    The file should be owned by the Messaging Server and reside in the same directory as the job_controller.cnf file. The following code example shows the lines you must add to the file:


    [CHANNEL=x_test]
    master_command=file-path
    

    In the above example, file-path is the full path to your executable program.

  5. Make sure your executable has permissions and ownership such that the Messaging Server can run it.

  6. Restart the Job Controller.

    Use the command found in the following code example:


    # imsimta restart job_controller
    

    If the program performing enqueues is also a channel that will be dequeuing messages, and more specifically, is doing intermediate processing that leaves the envelope recipient addresses unchanged, then special rewrite rules must be used to prevent a message loop in that the channel just enqueues the mail back to itself. For directions on how to prevent a message loop and other specific examples of rewrite rules, see Preventing Mail Loops when Re-enqueuing Mail.

ProcedureTo Manually Run Your Test Programs

Steps
  1. If the program does not explicitly set the channel name, then you must define the PMDF_CHANNEL environment variable.

    The value of that variable must be the name of your channel. The following example shows how to set the PMDF_CHANNEL environment variable:


    # PMDF_CHANNEL=x_test
    # export PMDF_CHANNEL

    For further information, see Running Your Enqueue and Dequeue Programs.

  2. Ensure that any environment variables required to run a program linked against the MTA SDK are defined.

    See Compiling and Linking Programs for additional information.

  3. Under some circumstances, it might be useful to comment out the master_command= line in the job_controller.site file.

    If you do this, you can enqueue mail to your test channel but not have the Job Controller actually run your channel program.

  4. When repeatedly testing your channel program, it is often necessary to restart the Job Controller before each manual test run.

    Otherwise, the Job Controller will hand off messages to your program on the first manual run but not the second manual run. The Job Controller will think that retries of the messages need to be delayed by several hours. By restarting the Job Controller, you cause it to “forget” which queued messages are to be deferred. Thus, when you run your channel again, it will be presented with all of the queued messages.