Skip to main content
This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.
 
developerWorks
AIX and UNIX
Information Mgmt
Lotus
New to Lotus
Products
How to buy
Downloads
Live demos
Technical library
Training
Support
Forums & community
Events
Rational
Tivoli
WebSphere
Java™ technology
Linux
Open source
SOA and Web services
Web development
XML
My developerWorks
About dW
Submit content
Feedback



developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum

developerWorks

  


RE: MQSeries Integration
benpoole 23.Apr.04 11:19 AM Lotus Notes
General 6.0 All Platforms


OK, I've found some code I put together some time back. It's a bit old -- could do with a tweak here and there, and only tested in Notes 5.0.11 -- but it works.

It's a class that encapsulates connecting to a specified MQ queue, with a simple method to return a message as a String object. You may want to modify for some decent logging, and also to work with your Notes application. I've annotated some of the bits you might want to change.

--

import com.ibm.mq.*;
import lotus.domino.*;

/**
* Encapsulates connection to Websphere MQ & grabs message
* Returns message as a string. You migh want to change this
*
* @author Ben Poole
* @version 0.10, 26 November 2003
*
**/
public class MQXMLConnection {
private final String CLASS_NAME = this.getClass().getName();
private String queuefield;

public MQXMLConnection() {
// Any init code goes in constructor here
}


/**
* Using parameters in the current Lotus Notes database,
* connects to specified MQ host & queue, returning
* message content as String object.
* <p>
* You may want to re-factor so that it's static
*
* @param db representing current (Notes) Database object
* @return String containing message from MQ
*/
public String getMessage(Database db) {
final String SETUP_VIEW = "vwLUSetup"; // your params view
final int WAIT_INT = 10000;

String hostName = null;
String queueName = null;
String channel = null;
String queueMgr = null;
int port = 0;
String msgText = null;

try {
View vwConfig = db.getView(SETUP_VIEW);
if(vwConfig==null) {
System.err.println(CLASS_NAME + ": configuration view in Notes application not found.");
return null;
}
Document doc = vwConfig.getFirstDocument();
int i;
if(doc != null) {
// Might want to change these field names
hostName = doc.getItemValueString("txtHostName");
channel = doc.getItemValueString("txtChannel");
queueName = doc.getItemValueString(queuefield);
queueMgr = doc.getItemValueString("txtQueueMgr");
port = doc.getItemValueInteger("numPort");
}

MQEnvironment.hostname = hostName;
MQEnvironment.channel = channel;
MQEnvironment.port = port;
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES);

MQQueueManager qMgr = new MQQueueManager(queueMgr);
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
MQQueue mqQ = qMgr.accessQueue(queueName, openOptions);
MQMessage retrievedMsg = new MQMessage();
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = MQC.MQGMO_WAIT | MQC.MQGMO_FAIL_IF_QUIESCING | MQC.MQGMO_NO_SYNCPOINT;
gmo.waitInterval = WAIT_INT;
mqQ.get(retrievedMsg,gmo);
int msgLen = retrievedMsg.getMessageLength();
msgText = retrievedMsg.readString(msgLen);
qMgr.commit();
mqQ.close();
qMgr.disconnect();
} catch(NotesException ne) {
System.err.println(CLASS_NAME + ": Domino exception: " + ne.id +
" - " + ne.text);
} catch (MQException mqe) {
System.err.println(CLASS_NAME + ": MQ exception: " + mqe.completionCode +
" - " + mqe.reasonCode);
} catch(Exception e) {
e.printStackTrace(); // Not proper handling. Sue me ;o)
}

return msgText;
}
}

--

HTH

--
http://www.benpoole.com




MQSeries Integration (Rishi Chauhan 23.Apr.04)
. . RE: MQSeries Integration (Ken A Collins 23.Apr.04)
. . . . RE: MQSeries Integration (benpoole 23.Apr.04)
. . . . . . RE: MQSeries Integration (Rishi Chauhan 23.Apr.04)
. . RE: MQSeries Integration (Greg-notes Walr... 23.Apr.04)
. . . . RE: MQSeries Integration (benpoole 23.Apr.04)
. . RE: MQSeries Integration (benpoole 23.Apr.04)
. . RE: MQSeries Integration (benpoole 23.Apr.04)
. . . . RE: MQSeries Integration (John Rush 16.Jun.05)


Document Options






  Document options
Print this pagePrint this page

Search this forum

Forum views and search


  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Author
Category
Platform
Release
Advanced search

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS
More Lotus RSS feeds

Resources

 Resources
Forum use and etiquette
Native Notes Access
Web site Feedback

Lotus Support

 Lotus Support
IBM Support Portal - Lotus software
Lotus Support documents
Lotus support by product
Lotus support downloads
Lotus support RSS feeds

Wikis

 Wikis
IBM Composite Applications
IBM Mashup Center
IBM Connections
IBM Connections Cloud Developers
IBM Docs
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud for Social Business
IBM Web Experience Factory
Lotus Domino
Lotus Domino Designer
Lotus Expeditor
Lotus Foundations
Lotus iNotes
Lotus Instructor Community Courseware
Lotus Notes
Lotus Notes & Domino Application Development
Lotus Notes Traveler
Lotus Protector
Lotus Quickr
Lotus Symphony
IBM Web Content Manager
WebSphere Portal

Lotus Forums


 Lotus Forums
Notes/Domino 9.0
Notes/Domino 8.5 + Traveler
Notes/Domino XPages development forum
Notes/Domino 8
Notes/Domino 6 and 7
IBM Connections
IBM Mobile Connect
IBM Sametime
IBM SmartCloud Notes
Lotus Enterprise Integration
Lotus Protector
Lotus Quickr
Lotus SmartSuite