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

Explanatory Text for Numbered Comments in the Simple Dequeue Example

The numbered explanatory text that follows corresponds to the numbered comments in Example 4–1:

  1. To start the dequeue processing, mtaDequeueStart() is called, and it calls process_message(), which processes each queued message. Since process_message() uses stdout for its output, only one message can be processed at a time. To effect that behavior, mtaDequeueStart() is called with the MTA_THREAD_MAX_THREADS set to one.

  2. If the call to mtaDequeueStart() succeeds, the program exits normally.

  3. If the call to mtaDequeueStart() fails, a diagnostic error message is displayed and the program exits with an error status.

  4. process_message() is called by mtaDequeueStart() for each queued message.

  5. The private context in process_message() tracks whether or not this is the first time the routine has been called. On the first call, the memory pointed at by my_ctx_2 is guaranteed to be NULL.

  6. The routine obtains each envelope recipient address, one at a time, using calls to mtaDequeueRecipientNext().

  7. Each recipient is marked as delivered using mtaDequeueRecipientDispostion(). An actual channel program would typically not make this call until after processing the message further.

  8. If process_message() returns without first dequeuing the message, mtaDequeueStart() defers the message for a later delivery attempt.

  9. The routine calls mtaDequeueLineNext() to read the message header and body, one line at a time. When there are no more lines to read, mtaDequeueLineNext() returns a status of MTA_EOF. When a line is read successfully, mtaDequeueLineNext() returns a status of MTA_OK.

  10. The lines returned by mtaDequeueLineNext() might not be NULL terminated because the returned line pointer might reference a line in a read-only, memory-mapped file.

  11. Once the message has been processed and all the disposition of all recipients set, mtaDequeueMessageFinish() is called. This actually dequeues the message.

  12. When all message processing is complete, process_message() exits. It is called again for each additional message to be processed.

Output from the Simple Dequeue Example

Received:from by (SunONE Messaging Server 6.0)id
 <\>; Fri, 21 Mar 2003 09:07:32 -0800(PST)
Date: Fri, 21 Mar 2003 09:07:41 -0800 (PST)
Subject: mtasdk_example1.c
Message-id: <\>
Content-transfer-encoding: 7BIT