Library Zone Articles
External Articles
Byte Size

Discovery Zone Catalogue
Diary
Links
Bookstore
Interactive Zone Ask the Gurus
Discussion Groups
Newsletters
Feedback
Etc Cartoons
Humour
COMpetition
Advertising
Site Builder ASP Web Ring ASP Web Ring

Click here
The Developer's Resource & Community Site
COM XML ASP Java & Misc. NEW: VS.NET
International This Week Forums Author Central Find a Job

Developing an MSMQ Server Application using VJ++

To work with any of these samples you will need the following:

  • Microsoft Visual J++ ver 6.0
  • Windows NT 4.0 Options Pack

1. Generate Java class wrappers from type libraries

Create simple Java class wrappers to call MSMQ Automation COM Objects. The JActiveX utility generates Java source code from type libraries. The DLL containing MSMQ type libraries can be located in \WINNT\System32 directory, and is called mqoa.dll.

D:\Program Files\Microsoft Visual Studio\VJ98>
D:\Program Files\Microsoft Visual Studio\VJ98>JActiveX /javatlb c:\winnt\system32\mqoa.dll
Microsoft TypeLib Importer For Java V5.00.2918
Copyright (C) 1997-1998 by Microsoft Corporation.
IMSMQMessage.java(Class): warning: skipped. Name is a keyword or conflicts with another member.
MQBOID.java(rgb): warning: skipped. Untranslatable typelib object.
MQXACTTRANSINFO.java(uow): warning: skipped. Cannot be used as a structure field.

D:\Program Files\Microsoft Visual Studio\VJ98>

The generated source code is placed in the \WINNT\Java\trustlib\mqoa directory of your machine

2. Develop the Server

MSMQServer.java
import com.ms.com.*;
import mqoa.*;

public class MSMQServer
{
 
/**
   * The main entry point for the application
   *
   * @param args Array of parameters passed to the
   * application via the comand line.
   */

  public static void main(String[] args)
  {
   
// This is the typeid that will be associated with the
    // new queue

    String typeID = "{E9E8CB90-D05E-11d2-B9D0-006097A7D34F}";
 
    Variant variantTrue = new Variant();
    Variant variantNoParam = new Variant();
    Variant guid = new Variant();
    Variant nop = new Variant((int)RELOPS.REL_NOP);
    Variant isEqual = new Variant((int)RELOPS.REL_EQ);
    Variant oneSecondDelay = new Variant();
    Variant theBody = new Variant();
    Variant transactionHolder = new Variant();
 
    IMSMQQueueInfo queueInfo = (IMSMQQueueInfo)new MSMQQueueInfo();
    IMSMQQueue queue = null;
    IMSMQMessage message = new MSMQMessage();
    IMSMQTransactionDispenser transactionDispenser = new MSMQTransactionDispenser();
    IMSMQTransaction transaction;

 
   
//Setting the variables
    variantTrue.putBoolean(true);
    variantNoParam.noParam();
    oneSecondDelay.putInt(1000);
 
    queueInfo.putPathName(".\\testQueue");
    queueInfo.putLabel("testQueue");
    queueInfo.putJournal(MQJOURNAL.MQ_JOURNAL);
    queueInfo.putServiceTypeGuid(typeID);

 
    try
    {
      queueInfo.Create(variantTrue,variantTrue);
    }
    catch(ComFailException except)
    {
    }
 
    queue = queueInfo.Open(MQACCESS.MQ_SEND_ACCESS, MQSHARE.MQ_DENY_NONE);
    theBody.putString("This is a test");
    message.putBody(theBody);
    message.putJournal(MQMSGJOURNAL.MQMSG_JOURNAL);
 
    transaction = transactionDispenser.BeginTransaction();

    try
    {
      transactionHolder.putDispatch(transaction);
      message.Send(queue,transactionHolder);
      transaction.Commit(variantNoParam, variantNoParam, variantNoParam);

    }
    catch(Exception transactionFailed)
    {
      transaction.Abort(variantNoParam, variantNoParam);
    }
  }
}



3. Compile and run the Server

(Now Go to Developing a Simple MSMQ Client....)


Author: Gopalan Suresh Raj

Gopalan Suresh Raj is a Software Architect, Developer and an active Author.

He is contributing author to a couple of books "Enterprise JavaComputing-Applications and Architecture"(Cambridge University Press, June '99) and "TheAwesome Power of JavaBeans"(Manning, July'98).

His expertise spans enterprise component architectures and distributed object computing. Visit him at his Web Cornucopia site (https://www.execpc.com/~gopalan)or mail him at [email protected].

Go to Gopalan's pages in Author Central.


Power your site with idr newswire

Contribute to IDR:

To contribute an article to IDR, a click here.

To contact us at IDevResource.com, use our feedback form, or email us.

To comment on the site contact our webmaster.

Promoted by CyberSavvy UK - website promotion experts

All content © Copyright 2000 IDevResource.com, Disclaimer notice

Java COM integration

Join the Developers Webring

Java COM integration

Join the Developers Webring

Learn C#