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

Explanatory Text for Numbered Comments in the Intermediate Channel Example

  1. The dequeue processing is initiated by calling mtaDequeueStart(). In this example, no global context is used; hence, the first call argument to mtaDequeueStart() is NULL.

  2. If the call to mtaDequeueStart() succeeds, then 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. Each dequeue thread calls process_done() as it exits. The intent is to allow the program to clean up and destroy any per-thread contexts created by the process_message() routine. In this case, the buffer used by rot13str() is deallocated.

  5. The mtaDequeueStart() routine calls process_message() once for each queued message to be processed. On the first call by a dequeue thread, the memory pointed at by my_ctx_2 is NULL.

  6. A message enqueue starts. The dequeue context, dq, is provided so that per-message envelope fields can be carried over to the new message from the message being dequeued.

  7. Each envelope recipient address is obtained, one at a time, with mtaDequeueRecipientNext(). When there are no more recipient addresses to obtain, mtaDequeueRecipientNext() returns the status MTA_EOF.

  8. Each envelope recipient address is added to the recipient list for the new message being enqueued. The MTA_ENV_TO option for mtaEnqueueTo() is specified so that the address is to be added to the new message’s envelope only. It should not also be added to the message’s RFC 822 header. The new message’s header will be a copy of the header of the message being dequeued. This copy is performed at the code location marked by comment 12.

  9. Each recipient is marked as delivered with mtaDequeueRecipientDisposition().

  10. In the event of an error returned from either mtaEnqueueTo() or mtaDequeueRecipientDisposition(), or an unexpected error return from mtaDequeueRecipientNext(), the ongoing enqueue is cancelled and the processing of the current message is deferred.

  11. Each line of the current message is read and then copied to the new message being enqueued. This copying continues until a blank line is read from the current message. (A blank line signifies the end of the RFC 822 message header and the start of the RFC 822 message content.)

  12. The code here needs to determine why it exited the read loop: because of an error, or because the transition from the message’s header to body was detected.

  13. The remainder of the current message is read line by line and copied to the new message being enqueued. However, the line enqueued is first transformed using the “rot13” transformation. The per-thread context my_ctx_2 is used to hold an output buffer used by the rot13str() routine.

  14. The enqueue of the new message is finished. If that step succeeds, then the message being dequeued is removed from the MTA queues.

  15. In the event of an error, the new message enqueue is cancelled and the current message left in the queues for later processing.

  16. The rot13 character transformation.

  17. A routine that applies the rot13 transformation to a character string.

Sample Input Message for the Intermediate Channel Example

The example that follows is a sample input message from the queue to be processed by the program found in Example 4–3.


Received: from frodo.west.siroe.com by frodo.west.siroe.com
 (Sun Java System Messaging Server 6 2004Q2(built Mar 24 2004))id
<0HCH00301E6GO700@frodo.west.siroe.com\> for sue@sesta.com; Fri,
 28 Mar 2003 14:51:52 -0800 (PST)
Date: Fri, 28 Mar 2003 14:51:52 -0800 (PST)
From: root@frodo.west.siroe.com
Subject: Testing
To: sue@sesta.com
Message-id: <0HCH00303E6GO700@frodo.west.siroe.com\>
MIME-version: 1.0

This is a test message.

Output from the Intermediate Channel Example

This example shows the output generated by the dequeue and re-enqueue program (Example 4–3).


Received: from sesta.com by frodo.west.siroe.com
 (Sun Java System Messaging Server 6 2004Q2 (built Mar 24 2003))id
<0HCH00301E7DOH00@frodo.west.wiroe.com\> for sue@sesta.com; Fri,
 28 Mar 2003 14:51:58 -0800 (PST)
Received: from frodo.west.siroe.com by frodo.west.siroe.com
 (Sun Java System Messaging Server 6 2004Q2 (built Mar 24 2003))id
<0HCH00301E7DOH00@frodo.west.wiroe.com\> for sue@sesta.com; Fri,
 28 Mar 2003 14:51:52 -0800 (PST)
Date: Fri, 28 Mar 2003 14:51:52 -0800 (PST)
From: root@frodo.west.siroe.com
Subject: Testing
To: sue@sesta.com
Message-id: <0HCH00303E6GO700@frodo.west.siroe.com\>
MIME-version: 1.0

Guvf vf n grfg zrffntr.