So far, all the messages and the message queues have been non-transacted. You can create transacted message queues that offer the following advantages:
While transacted message queues are more reliable, they do require more storage space and processing. In Windows CE transactions are limited to a single message. You must decide when creating a message queue whether it will be transactional or not. To do this you should add a PROPID_Q_TRANSACTION property when creating the message queue, using MQCreateQueue. This property's data should contain the constant MQ_TRANSACTIONAL to specify transaction support: aQueuePropId[cPropId] = PROPID_Q_TRANSACTION; aQueuePropVar[cPropId].vt = VT_UI1 ; aQueuePropVar[cPropId].bVal = MQ_TRANSACTIONAL ; cPropId++; Once a queue is created you cannot change its transactional properties. You can use the MQGetQueueProperties function to determine whether a queue is transacted or not. A message can be sent to a transacted queue, and you can specify whether that message should be transacted or not. The following code fragment specifies a transacted message: hr = MQSendMessage(hq, // Handle to open queue &msgprops, // Properties of message MQ_SINGLE_MESSAGE); // Single msg transaction For a non-transacted message MQ_SINGLE_MESSAGE is replaced by NULL. There is another very important difference between transacted and non-transacted message queues. The messages in a non-transacted message queue are lost when a Windows CE device is cold-booted this is because MSMQ isrestarted. The contents of transacted message queues are maintained in this situation. For this reason, queues that store important data for any length of time should probably be created as transactional.
|