3.2 Example 2: Web Order Entry
This example demonstrates web order entry as described in the Send Message in Transaction - Application (section 2.5.4) and Receive Message in Transaction – Application (section 2.5.7) use cases.
Prerequisites
See the common prerequisites defined in section 3.
The queue exists.
The application is authorized to send messages to the queue.
If a Directory Service is not being used, the application is configured with the address of the queue prior to the send operation.
The Transaction Coordinator is accessible to the application and the queue manager in order to coordinate the transaction execution.
The receiving application is authorized to receive messages from the queue.
The web server application and the web server Queue Manager are deployed on the same machine.
The back-end application and the back-end Queue Manager are deployed on the same machine.
Initial System State
To execute this example, the queue managers on the web servers, intermediary server, and back-end server are operating in the queue server roles.
The queue manager on the intermediary server is initialized to contain a transactional queue. The queue manager on each web server dynamically creates an outgoing queue if there are recoverable messages pending transfer to the transactional queue. There is no requirement to create queues on the other queue managers.
Final System State
The final states for the queue managers are equal to their initial states. The intermediary server Queue Manager contains a transactional queue, and the queue is in a ready state.
Sequence of Events
The sequence of events for web order entry is shown in the following figure.

Figure 20: Sequence diagram for Example 2
The web client transmits the customer order to the web server application using the Transmission Control Protocol/Internet Protocol (TCP/IP) and Hypertext Transfer Protocol (HTTP) protocols, as specified in [RFC2616].
The order is transformed into an MSMQ message by the web server application.
The web server application sends the MSMQ message to the web server Queue Manager, which stores the MSMQ message in its outgoing queue as described in steps 1 through 4 of Example 1: Disconnected Data Entry (section 3.1).
An order completion page is sent to the web client by the web server application.
The web server Queue Manager sends an MSMQ transactional message to the intermediary server Queue Manager as described in steps 5 through 7 of Example 1: Disconnected Data Entry (section 3.1).
The back-end application creates a new unique transactional unit of work identifier XACTUOW ([MS-MQMQ] section 2.2.18.1.8 structure and invokes the R_QMEnlistInternalTransaction ([MS-MQMP] section 3.1.4.14) method to create an internal transaction handle for the XACTUOW structure.
The back-end application receives the MSMQ message from the back-end Queue Manager by invoking the rpc_ACReceiveMessageEx ([MS-MQMP] section 3.1.5.3) method of the qmcomm2 interface, providing a ptb input parameter initialized with the XACTUOW structure created at step 6.
The back-end Queue Manager invokes the R_OpenQueue ([MS-MQRR] section 3.1.4.2) method, which returns a QUEUE_CONTEXT_HANDLE_SERIALIZE ([MS-MQRR] section 2.2.4.2) handle; next, it invokes the R_QMEnlistRemoteTransaction ([MS-MQRR] section 3.1.4.12) method to propagate the distributed atomic transaction context to the intermediary server Queue Manager. The back-end Queue Manager utilizes the QUEUE_CONTEXT_HANDLE_SERIALIZE identifier and invokes the R_StartTransactionalReceive ([MS-MQRR] section 3.1.4.13) method and the R_EndTransactionalReceive ([MS-MQRR] section 3.1.4.15) method to receive the message from the opened queue of the intermediary server Queue Manager. Then the back-end Queue Manager invokes the R_CloseQueue ([MS-MQRR] section 3.1.4.3) method to close the QUEUE_CONTEXT_HANDLE_SERIALIZE handle.<6>
The back-end application processes the received MSMQ message.
The back-end application commits the transaction by invoking the R_QMCommitTransaction ([MS-MQMP] section 3.1.4.15) method, specifying the internal transaction handle obtained at step 6.
The Distributed Transaction commits the MSMQ message as described in step 10 of Example 1: Disconnected Data Entry (section 3.1).
The intermediary server Queue Manager removes the MSMQ message from its order queue as described in steps 12 and 13 of Example 1: Disconnected Data Entry (section 3.1).
The back-end application sends an order completion email to the web client.