Deepthi 的个人资料Win with Win Mobile照片日志列表更多 工具 帮助

日志


12月6日

Message Queues in .net CF

I have been researching on message queues in .net cf, and its cool stuff :) !
 
MSMQ is a Microsoft message queueing technology that allows disparate applications, not necessarily running in the same machine, to send messages to one another.Message Queuing provides built-in enhanced security, transaction support, and other features.

MSMQ is useful when custom applications need to communicate reliably across potentially unreliable or occasionally connected networks. MSMQ is also useful as a persistent storage mechanism for a list of items. For example, a server-based application could use MSMQ to store queued orders that would be submitted as a batch to an order-processing system at the end of the day. Now what I did not know was that MSMQ is also the underpinning infrastructure for reliable messaging in Windows Communication Foundation, first available in Windows Vista, the next version of the client operating system.

Now how do I use MSMQ in my CF code ?

Go to Microsoft Mobile Development Center and follow the link "Redistributable Server Components for Windows Mobile 5.0" to download the package. We need the msmq.ARM.CAB file in the package.

  1. After downloading, extract the msmq.ARM.CAB file (under msmq folder in the downloaded package). This is the cab file that installs the MSMQ service in the device.
  2. Back in Visual Studio, right-click on your project in Solution Explorer and add msmq.ARM.CAB to your project (use Add-> Existing Item...). Then click on msmq.ARM.CAB in Solution Explorer and change its "Copy to Output Directory" property to "Copy if newer". This will ensure that the cab file is copied over to the program folder in the device.
  3. In your form code, import the namespaces:
    using System.IO;
    using System.Messaging;
    using System.Runtime.InteropServices

But just doing the above will not install the cab file (and the associated msmq isntallables) on the device/emulator. To do that, we manually have to install the cab file on the device /emulator. THis is howI did it on the emulator:

1.Place the msmq.ARM.CAB file in a folder

2.Open the File->'Configure'->Shared Folders-> Add the folder which contains the msmq.ARM.CAB file.

3.In the emulator Navigate to Start->Programs->File Explorer (Select the My Device option from the drop down on the top here ) -> StorageCard->YourFolderName->msmq.arm. Click on install-and bingo ! MSMQ is installed on your device/emulator now !

I spent a couple of exceptional (PUN INTENDED) hours trying to figure why MSMQ was not getting installed on my emulator, inspite of having the cab files added to my project.

Once we are done with the above steps, we are ready to use MSMQ !

Now to write code to send and receive messages frm using MSMQ, you can check out the following link (the one i referred to myself :) ) :

http://netcf2.blogspot.com/2006/01/msmq-message-queueing-in-compact.html

More on MSMQ in the next post..till then-Keep Messaging ! :)