Microsoft Message Queue (MSMQ) Component Template/Example
Directions:
- Make sure MSMQ is installed on the same machine as your IIS4/5 server. You can install
it from the NT Option Pack or, if using Windows 2000, go to
Start\Programs\Administrative Tools, click on Configure your Server, click on the
Advanced link, then click on the appropriate installation link. You do not need to
install an Enterprise/Public version of MSMQ to make this example work - choose an Independent
Client installation instead (if you don't already have it installed that is).
- Open VB6, start a new ActiveX DLL project, copy and paste the VB6 code below into the code
window, click on Project\References..., click on the checkbox next to
Microsoft Message Queue 2.0 Library, click on OK, change the Project name to MTGMSMQ,
change the Class name to MessageQueues, click on File\Make MTGMSMQ.DLL..., choose a
location where to save your component, click on OK, then register your component using
REGSVR32 C:\Path\MTGMSMQ.DLL or add it to an MTS Explorer Package or Application.
- Copy and paste the ASP code below into an ASP page named msmq.asp and store it into a
virtual directory that your IIS server can execute.
- Your ready - just run the msmq.asp page.
What the Example Does:
- The Message and Queue name variables are declared and set (lines 1-3).
- The ASP page instantiates the custom component MTGMSMQ.MessageQueues (line 4).
- A new queue is created named testqueue (line 5).
- A message is sent to the queue (line 6).
- The message is read then written to the ASP page (line 7).
- The Queue is destroyed (line 8).
- The component object is destroyed (line 9).
ASP/VBScript Code for Example:
VB6 MSMQ Component Template/Example:
|