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

Basic Dequeuing Steps

The following basic steps are necessary to dequeue messages:

  1. Initialize SDK resources and data structures with mtaInit().

  2. Call mtaDequeueStart(), passing it the address of the caller-supplied routine that is to be used to process each message.

    When mtaDequeueStart() is called, it does not return until all queued messages requiring processing have been processed, thus blocking the thread calling it until it is finished.

  3. For each queued message requiring processing, an execution thread created by mtaDequeueStart() calls the routine whose address was provided in Step 2.

    Threads created by mtaDequeueStart() each sequentially process multiple messages. That is, mtaDequeueStart() does not create a distinct thread for each and every queued message to be processed.

    For a list of the tasks the processing routine should do, see Caller-Supplied Processing Routine.


    Note –

    The mtaDequeueStart() routine will use one or more threads, with each thread calling the message processing routine. The maximum number of threads allowed can be set when calling mtaDequeueStart(). Consequently, a program that does not support threading should specify a maximum of one thread when it calls mtaDequeueStart.


    For a list of the tasks the processing routine should do, see Dequeue Message Processing Routine Tasks.

  4. After mtaDequeueStart() returns, deallocate SDK resources and data structures with a call to mtaDone().