At run time, when your program enqueues a message to, or dequeues a message from the MTA, the SDK must be able to determine the name of the MTA channel under which to perform the enqueue or dequeue. If this name cannot be determined, then the enqueue or dequeue operation will fail. Consequently, when calling mtaEnqueueStart() or mtaDequeueStart(), a channel name can be specified. Whether or not you need to specify this channel name depends upon the conditions under which your program runs. While developing your program and manually running it, you may either code the channel name into your program or specify it through your run time environment with the PMDF_CHANNEL environment variable. For example, to do the latter on UNIX® platforms use a command of the following form:
# PMDF_CHANNEL=channel-name program-name
where channel-name is the name of the channel and program-name is the name of the executable program to run.
In production, if your program will run as a master or slave channel program under the MTA Job Controller, then you do not need to specify the channel name; it will automatically be set by the Job Controller using the PMDF_CHANNEL environment variable. If, however, your program will be run manually or as a server, then either the program can specify its channel name through code or using the PMDF_CHANNEL environment variable. For the latter, setting the environment variable is typically achieved by wrapping your executable program with a shell script. The shell script would set the environment and then invoke your program, as illustrated in the following code example:
#!/bin/sh PMDF_CHANNEL=channel-name PMDF_CHANNEL_OPTION=option-file-path export PMDF_CHANNEL PMDF_CHANNEL_OPTION program-name exit
The option-file-path shown in the previous example is the full, absolute path to the channel’s option file, if any.
A program can query the SDK to determine what channel name is being used with either the mtaChannelGetName(), mtaEnqueueInfo(), or mtaDequeueInfo() routines. The former returns the channel name the SDK will use when no other name is explicitly specified through code. The latter two return the name specifically being used with a given enqueue or dequeue context.
The SDK only reads the PMDF_CHANNEL environment variable once per program invocation. As such, running code cannot expect to change its channel name by changing the value of the environment variable.