The information in this article applies to:
- Microsoft Message Queue Server version 1.0
SUMMARY
Using Microsoft Message Queue Server (MSMQ) ActiveX components from Java is
similar to using any other ActiveX objects from the Java environment.
Following are the basic "getting started" steps with Java and MSMQ ActiveX
components.
MORE INFORMATION
How to Use ActiveX Components from Microsoft Visual J++ 1.1
"Using Java and COM" topic in Visual J++ Books Online describes how to use
COM with Java. Visual J++ 1.1 includes several Java/COM samples.
What MSMQ ActiveX Components are Available
Read the information in MSMQ SDK, especially the following topics:
- MSMQ Guide\MSMQ ActiveX Support
- Using MSMQ\Using the ActiveX Components
How To Create an MSMQ Application Using Java Applet Wizard
Here are the basic "getting started" steps with Java and MSMQ ActiveX
components using Microsoft Visual J++ 1.1, which is included with Microsoft
Visual Studio 97. This project shows how to create an MSMQ queue using Java
code:
- Create a basic Visual J++ project using Java Applet Wizard. Select "As
an applet only" in Step 1, "HTML file" in Step 2, "multi-threaded" and
"no animation" in Step 3, and then click Finish.
This creates two source files in the project. One is a .java file for
the java class and the other is an .html file for VBScript (given
below):
<html>
<head>
<title>MQJava</title>
</head>
<body>
<hr>
<applet
code=MQJava.class
name=MQJava
width=320
height=240 >
</applet>
<hr>
<a href="MQJava.java">The source.</a>
</body>
</html>
- Run "Java Type Library Wizard" on "Microsoft Message Queue Object
Library":
The MSMQ installation program creates the registry entries for MSMQ
ActiveX components and interfaces so that the typelib gets registered.
Before building the project, make sure you run the Java Type Library
Wizard from the Tools menu in DevStudio IDE. Select "Microsoft Message
Queue Object Library" from the list, which creates the .class files in
your Winnt\Java\Trustlib\Mqoa folder. The folder also contains a
Summary.txt file that contains information about the Java classes
derived from the information in the typelib. Make sure you use the
method names given in this file for the interface you are using.
- Include the following lines near the top of your .java file created by
the wizard:
import mqoa.* ;
import com.ms.com.Variant;
- Add the following method to create an MSMQ queue:
public void CreateQueue()
{
Variant isTransactional;
Variant isWorldReadable;
IMSMQQueueInfo qinfo = (IMSMQQueueInfo)new MSMQQueueInfo();
qinfo.putPathName(".\\qJava");
isTransactional = new Variant();
isTransactional.putBoolean(false);
isWorldReadable = new Variant();
isWorldReadable.putBoolean(false);
qinfo.Create(isWorldReadable, isTransactional);
}
Call the method CreateQueue() from Init() method and run MSMQ Explorer to
verify that the queue has been created. If the queue already exists (if you
run it twice), you will get a Java exception dialog box on the Web page.
REFERENCES
For more information, see the following topics in MSMQ SDK:
- "MSMQ Guide'\MSMQ ActiveX Support"
- "Using MSMQ'\'Using the ActiveX Components"
(c) Microsoft Corporation 1997, All Rights Reserved. Contributions by Syed
Yousuf, Microsoft Corporation
Keywords : MQProg kbfaq
Version : WinNT:1.0
Platform : winnt
Issue type : kbhowto