Csqzaw 00
Csqzaw 00
Using Java
SC34-5456-00
MQSeries IBM
Using Java
SC34-5456-00
Note!
Before using this information and the product it supports, be sure to read the general information under Appendix A, “Notices”
on page 119.
Order publications through your IBM representative or the IBM branch office serving your locality. Publications are not stocked at
the address given below.
At the back of this publication is a page titled “Sending your comments to IBM”. If you want to make comments, but the methods
described are not available to you, please address them to:
When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any way it believes
appropriate without incurring any obligation to you.
Contents
About this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Who this book is for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
What you need to know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
How to use this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Changes in this version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
MQSeries publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii
MQSeries cross-platform publications . . . . . . . . . . . . . . . . . . . . . . viii
MQSeries platform-specific publications . . . . . . . . . . . . . . . . . . . . . . xi
MQSeries Level 1 product publications . . . . . . . . . . . . . . . . . . . . . . xii
Softcopy books . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
MQSeries information available on the Internet . . . . . . . . . . . . . . . . . . xiv
Multithreaded programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Writing user exits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Compiling and testing MQSeries classes for Java programs . . . . . . . . . . . 35
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Figures
1. MQSeries classes for Java example applet . . . . . . . . . . . . . . . . . 23
2. MQSeries classes for Java example application . . . . . . . . . . . . . . . 26
Tables
1. Platforms and connection modes . . . . . . . . . . . . . . . . . . . . . . . . 5
2. Installation directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3. Sample CLASSPATH statements . . . . . . . . . . . . . . . . . . . . . . . . 7
4. AIX and HP-UX environment variables . . . . . . . . . . . . . . . . . . . . . 7
5. Core classes restrictions and variations . . . . . . . . . . . . . . . . . . . 40
6. Character set identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Figures v
Tables
Part 1 describes the use of MQSeries classes for Java, Part 2 provides assistance
for programmers, and Part 3 contains detailed information about the MQSeries
classes for Java.
MQSeries publications
This section describes the documentation available for all current MQSeries
products.
Any exceptions to this general rule are indicated. (Publications that support the
MQSeries Level 1 products are listed in “MQSeries Level 1 product publications” on
page xii. For a functional comparison of the Level 1 and Level 2 MQSeries
products, see the MQSeries Planning Guide.)
MQSeries Brochure
The MQSeries Brochure, G511-1908, gives a brief introduction to the benefits of
MQSeries. It is intended to support the purchasing decision, and describes some
authentic customer use of MQSeries.
MQSeries: An Introduction to Messaging and Queuing
MQSeries: An Introduction to Messaging and Queuing, GC33-0805, describes
briefly what MQSeries is, how it works, and how it can solve some classic
interoperability problems. This book is intended for a more technical audience than
the MQSeries Brochure.
MQSeries Planning Guide
The MQSeries Planning Guide, GC33-1349, describes some key MQSeries
concepts, identifies items that need to be considered before MQSeries is installed,
including storage requirements, backup and recovery, security, and migration from
earlier releases, and specifies hardware and software requirements for every
MQSeries platform.
MQSeries Intercommunication
The MQSeries Intercommunication book, SC33-1872, defines the concepts of
distributed queuing and explains how to set up a distributed queuing network in a
variety of MQSeries environments. In particular, it demonstrates how to (1)
configure communications to and from a representative sample of MQSeries
products, (2) create required MQSeries objects, and (3) create and configure
MQSeries channels. The use of channel exits is also described.
MQSeries Clients
The MQSeries Clients book, GC33-1632, describes how to install, configure, use,
and manage MQSeries client systems.
MQSeries System Administration
The MQSeries System Administration book, SC33-1873, supports day-to-day
management of local and remote MQSeries objects. It includes topics such as
security, recovery and restart, transactional support, problem determination, and the
dead-letter queue handler. It also includes the syntax of the MQSeries control
commands.
This book applies to the following MQSeries products only:
MQSeries for AIX V5.1
MQSeries for HP-UX V5.1
MQSeries for OS/2 Warp V5.1
MQSeries for Sun Solaris V5.1
MQSeries for Windows NT V5.1
Softcopy books
Most of the MQSeries books are supplied in both hardcopy and softcopy formats.
BookManager format
The MQSeries library is supplied in IBM BookManager format on a variety of online
library collection kits, including the Transaction Processing and Data collection kit,
SK2T-0730. You can view the softcopy books in IBM BookManager format using
the following IBM licensed programs:
BookManager READ/2
BookManager READ/6000
BookManager READ/DOS
BookManager READ/MVS
BookManager READ/VM
BookManager READ for Windows
HTML format
Relevant MQSeries documentation is provided in HTML format with these
MQSeries products:
MQSeries for AIX V5.1
MQSeries for HP-UX V5.1
MQSeries for OS/2 Warp V5.1
MQSeries for Sun Solaris V5.1
MQSeries for Windows NT V5.1 (compiled HTML)
MQSeries link for R/3 V1.2
The MQSeries books are also available in HTML format from the MQSeries product
family Web site at:
http://www.software.ibm.com/ts/mqseries/
If you need to obtain the Adobe Acrobat Reader, or would like up-to-date
information about the platforms on which the Acrobat Reader is supported, visit the
Adobe Systems Inc. Web site at:
http://www.adobe.com/
PDF versions of relevant MQSeries books are supplied with these MQSeries
products:
MQSeries for AIX V5.1
MQSeries for HP-UX V5.1
MQSeries for OS/2 Warp V5.1
MQSeries for Sun Solaris V5.1
MQSeries for Windows NT V5.1
MQSeries link for R/3 V1.2
PDF versions of all current MQSeries books are also available from the MQSeries
product family Web site at:
http://www.software.ibm.com/ts/mqseries/
PostScript format
The MQSeries library is provided in PostScript (.PS) format with many MQSeries
Version 2 products. Books in PostScript format can be printed on a PostScript
printer or viewed with a suitable viewer.
http://www.software.ibm.com/ts/mqseries/
messaging means that a simple request from the browser can be expanded safely
into a sequence of individual back-end processes in a transactional manner.
The MQSeries classes for Java also enable application developers to exploit the
power of the Java programming language to create applets and applications that
can run on any platform that supports the Java run-time environment. These
factors combine to reduce significantly the development time for multi-platform
MQSeries applications, and future enhancements to applets are automatically
picked up by end users as the applet code is downloaded.
Connection options
Programmable options allow the MQSeries classes for Java to connect to
MQSeries in three distinct ways:
As an MQSeries client using TCP/IP
Using VisiBroker for Java
In bindings mode, connecting directly to MQSeries
These options are described in more detail below.
Client connection
If you are using the MQSeries classes for Java as an MQSeries client, they can be
installed either on the MQSeries server machine, which may also contain a Web
server, or on a separate machine. Installation on the same machine as a Web
server has the advantage of allowing you to download and run MQSeries client
applications on machines that do not have the MQSeries classes for Java installed
locally.
Wherever you choose to install the client, it can be run in three different modes:
From within any Java-enabled Web browser
When running in this mode, the locations of the MQSeries queue managers
that can be accessed may be constrained by the security restrictions of the
browser being used.
Using an applet viewer
To use this method you must have the Java Developer's Kit (JDK) or Java
Runtime Environment (JRE) installed on the client machine.
As a stand-alone Java program or in a Web application server
To use this method you must have the Java Developer's Kit (JDK) or Java
Runtime Environment (JRE) installed on the client machine.
Bindings connection
When used in bindings mode, the MQSeries classes for Java use the JNI to call
directly into the existing queue manager API rather than communicating through a
network. This provides better performance for MQSeries classes for Java
applications than using network connections. Unlike the client mode, applications
written using the bindings mode cannot be downloaded as applets.
To use the bindings connection, the MQSeries classes for Java must be installed
on the MQSeries server.
Prerequisites
The following software is required to run the MQSeries classes for Java:
MQSeries for the server platform you wish to use. Table 1 shows the
connection modes that can be used for each platform.
Notes:
1. If you want to use the native connection (bindings) mode, you must install from
the server CD.
2. On an OS/2 system, the MQSeries classes for Java must be installed in an
HPFS partition.
The MQSeries classes for Java files, documentation, and samples are installed in
the directories shown in Table 2.
The procedures depend on the connection option you want to use. Follow the
instructions in the section that is appropriate for your requirements.
The applet connects to a given queue manager, exercises all the MQSeries calls,
and produces diagnostic messages in the event of any failures.
The applet can be run from the applet viewer supplied with your JDK (v1.1.6 or
later), or any Java 1.1.6 enabled browser. When using the applet viewer you will
be able to access a queue manager on any host. When using a Web browser, you
will be able to access a queue manager only on the host from which the applet was
loaded. This is your local machine if you have the MQSeries classes for Java
installed, or the machine on which your Web server is running if you download the
applet from a Web server.
Note: When loading applets from a local installation, some Web browsers allow
you to specify only the literal string "localhost" as the name of the host to connect
to. Consult your Web browser documentation for further information.
In all cases, if the applet does not complete successfully, follow the advice given in
the diagnostic messages and try to run the applet again.
TCP/IP client
1. Define a server connection channel using the following procedure:
a. Start your queue manager using the strmqm command
b. Type
runmqsc
to start the runmqsc program
c. Define a sample channel called JAVA.CHANNEL by typing:
DEF CHL('JAVA.CHANNEL') CHLTYPE(SVRCONN) TRPTYPE(TCP) MCAUSER(' ') +
DESCR('Sample channel for MQSeries Client for Java')
Notes:
1. On some platforms the command is 'applet', and not 'appletviewer'.
2. On some platforms, you may need to select 'Properties' from the 'Applet' menu
at the top left of your screen, and then set 'Network Access' to 'Unrestricted'.
Using this technique you should be able to connect to any queue manager running
on any host to which you have TCP/IP access.
Tests complete -
SUCCESS: This transport is functioning correctly.
Press Enter to continue...
4. At prompt (1):
For information on writing MQSeries Java applications and applets, see Part 2,
“Programming with the MQSeries classes for Java” on page 15.
If you continue to have problems and need to contact the IBM service team, you
may be asked to turn on the trace facility. The method of doing this depends on
whether you are running the client or the bindings. Choose the appropriate section
below to find the procedures for your system.
In the line
<!PARAM name="trace" value="1">
remove the exclamation mark, and change the value from 1 to a number from 1 to
5 depending on the level of detail required. (The higher the number, the more
information will be gathered.)
The trace output appears in the Java console or in your Web browser's Java log
file.
For more information on using trace, and how to find and use the output on your
platform, see MQSeries System Administration.
Error messages
Here are some of the more common error messages that you may see:
Unable to identify local host IP address
The server is not connected to the network.
Recommended Action: Connect the server to the network and retry.
Unable to load file gatekeeper.ior
This failure can occur on a web server deploying VisiBroker applets, when the
gatekeeper.ior file is not located in the correct place.
Recommended Action: Restart the VisiBroker Gatekeeper from the directory in
which the applet is deployed. The gatekeeper file will be written to this
directory.
Failure: Missing software, may be MQSeries, or VBROKER_ADM variable
This failure occurs in the MQIVP sample program if your Java software
environment is incomplete.
Recommended Action: On the client, ensure that the VBROKER_ADM
environment variable is set to address the VisiBroker for Java administration
(adm) directory, and retry.
On the server, ensure that the MQSeries classes for Java from MQSeries
Version 5.1 are installed and retry.
NO_IMPLEMENT
There is a communications problem involving VisiBroker Smart Agents.
Recommended Action: Consult your VisiBroker documentation.
COMM_FAILURE
There is a communications problem involving VisiBroker Smart Agents.
Recommended Action: Use the same port number for all VisiBroker Smart
Agents and retry. Consult your VisiBroker documentation.
MQRC_ADAPTER_NOT_AVAILABLE
If you get this error when you are trying to use Visibroker, it is likely that the
Java class org.omg.CORBA.ORB cannot be found in the CLASSPATH.
Recommended action: Ensure that your CLASSPATH statement includes the
path to the Visibroker vbjorb.jar and vbjapp.jar files.
Using the procedural interface, you disconnect from a queue manager using the
call MQDISC(Hconn, CompCode, Reason), where Hconn is a handle to the queue
manager.
If you do not have the right JDK, go to the IBM Software Download Catalog which
is available on the World Wide Web at location:
http: //www.software.ibm.com/download
You can also develop applications using the JDK included with the integrated
development environment of IBM Visual Age for Java.
This chapter provides information to assist with writing Java applets, servlets, and
applications to interact with MQSeries systems. For details of individual classes,
see Chapter 7, “The Java classes and interfaces for MQSeries” on page 45.
Connection differences
The way you program the MQSeries classes for Java has some dependencies on
the connection modes you want to use.
Client connections
When the MQSeries classes for Java are used as a client, it is similar to the
MQSeries C client, but has the following differences:
It supports only TCP/IP.
It does not support connection tables.
It does not read any MQSeries environment variables at startup.
Information that would be stored in a channel definition and in environment
variables is stored in a class called MQEnvironment, or can be passed as
parameters when the connection is made.
Error and exception conditions are written to a log specified in the
MQException class. The default error destination is the Java console.
The MQSeries classes for Java clients do not support the MQBEGIN verb or fast
bindings.
For general information on MQSeries clients see the MQSeries Clients book.
Note: When you use the VisiBroker connection, the userid and password settings
in MQEnvironment are not forwarded to the MQSeries server. The effective userid
is that which applies to the IIOP server.
Bindings mode
The bindings mode of the MQSeries classes for Java differs from the client modes
in the following ways:
Most of the parameters provided by the MQEnvironment class are ignored.
The bindings support the MQBEGIN verb and fast bindings into the MQSeries
queue manager.
MQEnvironment.hostname
Set the value of this variable follows:
For client connections, set this to the hostname of the MQSeries server to
which you want to connect
For bindings mode, set this to null
// ===========================================================================
//
// Licensed Materials - Property of IBM
//
// 5639-C34
//
// (c) Copyright IBM Corp. 1995,1999
//
// ===========================================================================
// MQSeries Client for Java sample applet
//
// This sample runs as an applet using the appletviewer and HTML file,
// using the command :-
// appletviewer MQSample.html
// Output is to the command line, NOT the applet viewer window.
//
// Note. If you receive MQSeries error 2 reason 2ð59 and you are sure your
// MQSeries and TCP/IP setup is correct,
// you should click on the "Applet" selection in the Applet viewer window
// select properties, and change "Network access" to unrestricted.
} // end of init
try {
// Create a connection to the queue manager
qMgr = new MQQueueManager(qManager);
// Now specify the queue that we wish to open, and the open options...
MQQueue system_default_local_queue =
qMgr.accessQueue("SYSTEM.DEFAULT.LOCAL.QUEUE",
openOptions,
null, // default q manager
null, // no dynamic q name
null); // no alternate user id
// Define a simple MQSeries message, and write some text in UTF format..
system_default_local_queue.put(hello_world,pmo);
system_default_local_queue.get(retrievedMessage, gmo);
// And prove we have the message by displaying the UTF message text
system_default_local_queue.close();
qMgr.disconnect();
// If an error has occurred in the above, try to identify what went wrong.
// Was it an MQSeries error?
} // end of start
} // end of sample
// ======================================================================
// Licensed Materials - Property of IBM
// 5639-C34
// (c) Copyright IBM Corp. 1995, 1999
// ======================================================================
// MQSeries classes for Java sample application
//
// This sample runs as a Java appication using the command :- java MQSample
java.util.Hashtable properties;
MQQueue system_default_local_queue =
qMgr.accessQueue("SYSTEM.DEFAULT.LOCAL.QUEUE",
openOptions,
null, // default q manager
null, // no dynamic q name
null); // no alternate user id
// Define a simple MQSeries message, and write some text in UTF format..
// Define a simple MQSeries message, and write some text in UTF format..
system_default_local_queue.put(hello_world,pmo);
system_default_local_queue.get(retrievedMessage, gmo);
// And prove we have the message by displaying the UTF message text
system_default_local_queue.close();
qMgr.disconnect();
}
// If an error has occurred in the above, try to identify what went wrong
// Was it an MQSeries error?
} // end of sample
The "C" based MQSeries clients rely on environment variables to control the
behavior of the MQCONN call. Because Java applets have no access to
environment variables, the Java programming interface includes a class
MQEnvironment, which allows you to specify the following details that are to be
used during the connection attempt:
Channel name
Hostname
Port number
User ID
Password
To specify the channel name and hostname use the following code:
MQEnvironment.hostname = "host.domain.com";
MQEnvironment.channel = "java.client.channel";
This is equivalent to an MQSERVER environment variable setting of:
"java.client.channel/TCP/host.domain.com".
Note: If you are setting up a connection using VisiBroker for Java, see “Changing
the connection to use VisiBroker for Java” on page 25.
To disconnect from a queue manager, call the disconnect() method on the queue
manager:
queueManager.disconnect();
Calling the disconnect method causes all open queues and processes that you
have accessed through that queue manager to be closed. It is good programming
practice, however, to close these resources yourself when you have finished using
them. You do this with the close() method.
The commit() and backout() methods on a queue manager replace the MQCMIT
and MQBACK calls of the procedural interface.
The options parameter is the same as the Options parameter in the MQOPEN call.
When you have finished using the queue, close it using the close() method, as in
the following example:
queue.close();
With the MQSeries classes for Java you can also create a queue using the
MQQueue constructor. The parameters are exactly the same as for the
accessQueue method, with the addition of a queue manager parameter. For
example:
MQQueue queue = new MQQueue(queueManager,
"qName",
MQC.MQOO_OUTPUT,
"qMgrName",
"dynamicQName",
"altUserId");
Constructing a queue object in this way enables you to write your own subclasses
of MQQueue.
When you have finished using the process object, close it using the close()
method, as in the following example:
process.close();
With the MQSeries classes for Java you can also create a process using the
MQProcess constructor. The parameters are exactly the same as for the
accessProcess method, with the addition of a queue manager parameter.
Constructing a process object in this way enables you to write your own subclasses
of MQProcess.
Handling messages
You put messages onto queues using the put() method of the MQQueue class, and
you get messages from queues using the get() method of the MQQueue class.
Unlike the procedural interface, where MQPUT and MQGET put and get arrays of
bytes, the Java programming language puts and gets instances of the MQMessage
class. The MQMessage class encapsulates the data buffer that contains the actual
message data, together with all the MQMD parameters that describe that message.
To build a new message, create a new instance of the MQMessage class, and use
the writeXXX methods to put data into the message buffer.
When the new message instance is created, all the MQMD parameters are
automatically set to their default values, as defined in the MQSeries Application
Programming Reference. The put() method of MQQueue also takes an instance of
the MQPutMessageOptions class as a parameter. This class represents the
MQPMO structure.
The following example shows the creation of a message and putting it onto a
queue:
// Build a new message containing my age followed by my name
MQMessage myMessage = new MQMessage();
myMessage.writeInt(25);
The number format used by the read and write methods can be altered by setting
the encoding member variable.
The character set to use for reading and writing strings can be altered by setting
the characterSet member variable.
Handling errors
Methods in the Java interface do not return a completion code and reason code.
Instead, they throw an exception whenever the completion code and reason code
resulting from an MQSeries call are not both zero. This simplifies the program logic
so that you do not have to check the return codes after each call to MQSeries.
You can decide at which point in your program you want to deal with the possibility
of failure by surrounding your code with 'try' and 'catch' blocks, as in the following
example:
try {
myQueue.put(messageA,putMessageOptionsA);
myQueue.put(messageB,putMessageOptionsB);
}
catch (MQException ex) {
// This block of code is only executed if one of
// the two put methods gave rise to a non-zero
// completion code or reason code.
System.out.println("An error occurred during the put operation:" +
"CC = " + ex.completionCode +
"RC = " + ex.reasonCode);
}
When you create a new queue manager object using the new operator, it is
automatically opened for 'inquiry'. When you access a process object using the
accessProcess() method, it is automatically opened for 'inquiry'. When you access
a queue object using the accessQueue() method, it is not automatically opened for
either 'inquire' or 'set' operations, because automatically adding these options can
cause problems with some types of remote queues. To use the inquire, set, and
getXXX/setXXX methods on a queue, you must specify the appropriate 'inquire' and
'set' flags in the openOptions parameter of the accessQueue() method.
selectors[ð] = MQIA_DEF_PRIORITY;
selectors[1] = MQCA_Q_DESC;
queue.inquire(selectors,intAttrs,charAttrs);
Multithreaded programs
Multithreaded programs are hard to avoid in Java. Consider a simple program that
connects to a queue manager and opens a queue at startup. The program
displays a single button on the screen and, when the button is pressed, it fetches a
message from the queue.
With the "C" based MQSeries client this would cause a problem, since handles
cannot be shared across multiple threads. The MQSeries classes for Java relax
this constraint, allowing a queue manager object (and its associated queue and
process objects) to be shared across multiple threads.
The implementation of the MQSeries classes for Java ensures that, for a given
connection (queue manager object instance), all access to the target MQSeries
queue manager is synchronized. This means that a thread wishing to issue a call
to a queue manager is blocked until all other calls in progress for that connection
have completed. If you require simultaneous access to the same queue manager
from within your program, create a new queue manager object for each thread
requiring concurrent access. (This is equivalent to issuing a separate MQCONN
call for each thread.)
To implement an exit, you define a new Java class that implements the appropriate
interface. There are three exit interfaces defined in the MQSeries package:
MQSendExit
MQReceiveExit
MQSecurityExit
The agentBuffer parameter contains the data that is about to be sent (in the case of
the send exit), or has just been received (in the case of the receive and security
exits). There is no need for a length parameter, because the expression
agentBuffer.length tells you the length of the array.
For the Send and Security exits, your exit code should return the byte array that
you wish to be sent to the server. For a Receive exit, your code should return the
modified data that you wish to be interpreted by the MQSeries classes for Java.
If your program is to run as a downloaded Java applet, note that under the security
restrictions placed on it you will not be able to read or write any local files. If your
exit needs a configuration file, you can place the file on the web and use the
java.net.URL class to download it and examine its contents.
If you are writing MQSeries classes for Java applets, run your program either by
loading this HTML file into a Java enabled web browser, or by using the
appletviewer that comes with the Java Development Kit (JDK).
If your program is an application, or you are running it from your local disk using
the appletviewer command, you also have the option of redirecting the trace output
to a file of your choice.
The following code fragment shows an example of how to make the redirection to a
file called myapp.trc:
import java.io.\;
try {
FileOutputStream
traceFile = new FileOutputStream("myapp.trc");
MQEnvironment.enableTracing(2,traceFile);
}
catch (IOException ex) {
// couldn't open the file,
// trace to System.err instead
MQEnvironment.enableTracing(2);
}
To trace methods in the Java Virtual Machine with trace level 5, issue the
command java_g in place of java to run an application, or appletviewer_g instead
of appletviewer to run an applet.
The MQSeries classes for Java provide a 'core' of classes, which provide
consistent function and behavior in all the environments, and 'V5 extensions', which
are designed for use only in environments 4 and 5. The core and extensions are
documented below.
Core details
The MQSeries classes for Java contain the following core of classes, which can be
used in all environments with only the minor variations listed in “Restrictions and
variations for core classes” on page 40.
MQEnvironment
MQException
MQGetMessageOptions
Excluding:
– MatchOptions
– GroupStatus
– SegmentStatus
– Segmentation
MQManagedObject
Excluding:
– inquire()
– set()
MQMessage
Excluding:
– groupId
– messageFlags
– messageSequenceNumber
– offset
– originalLength
MQPutMessageOptions
Excluding:
– knownDestCount
– unknownDestCount
– invalidDestCount
– recordFields
MQProcess
MQQueue
MQQueueManager
Excluding:
– begin()
– accessDistributionList()
MQC
Some constants are not included in the core (see “Restrictions and variations for
core classes” for details), and you should not use them in completely portable
programs.
Apart from these documented variations, the core classes give consistent behavior
across all environments, even if the equivalent MQSeries classes normally have
environment differences. In general, the behavior will be that expected in
environments 4 and 5.
MQGetMessageOptions options.
The following flags may be set into the MQGetMessageOptions options fields in
any environment, but if used with a subsequent MQQueue.get() in any
environment other than 4 or 5, the get() fails with MQRC_OPTIONS_ERROR:
MQGMO_SYNCPOINT_IF_PERSISTENT
MQGMO_LOGICAL_ORDER
MQGMO_COMPLETE_MESSAGE
MQGMO_ALL_MSGS_AVAILABLE
MQGMO_ALL_SEGMENTS_AVAILABLE
MQGetMessageOptions fields
Values may be set into the following fields, regardless of the environment, but if
the MQGetMessageOptions used on a subsequent MQQueue.get() is found to
contain non-default values when running in any environment other than 4 or 5,
the get() fails with MQRC_GMO_ERROR. This means that in environments
other than 4 or 5, these fields will always be set to their initial values after every
successful get().
MatchOptions
GroupStatus
SegmentStatus
Segmentation
Distribution Lists
The following classes are used to create Distribution Lists:
MQDistributionList
MQDistributionListItem
MQMessageTracker
You can be create and populate MQDistributionList and MQDistributionListItems
in any environment, but you can only create and open MQDistributionList
successfully in environments 4 and 5. An attempt to create and open one in any
other environment is rejected with MQRC_OD_ERROR.
MQPutMessageOptions fields
Four fields in MQPMO are rendered as the following member variables in the
MQPutMessageOptions class:
knownDestCount
unknownDestCount
invalidDestCount
recordFields
Although primarily intended for use with distribution lists, the MQSeries V5
server also fills in the DestCount fields after an MQPUT to a single queue. For
example, if the queue resolves to a local queue, then knownDestCount is set to
1 and the other two fields to 0. In environments 4 and 5, the values set by the
V5 server are returned in the MQPutMessageOptions class. In the other
environments return values are simulated as follows:
If the put() succeeds, unknownDestCount is set to 1, and the others are set
to 0.
If the put() fails, invalidDestCount is set to 1, and the others to 0.
recordFields is used with distribution lists. A value may be written into
recordFields at any time, regardless of the environment, but is ignored if the
MQChannelDefinition
java.lang.Object
│
└─ com.ibm.mq.MQChannelDefinition
Variables
channelName
public String channelName
The name of the channel through which the connection is established.
queueManagerName
public String queueManagerName
The name of the queue manager to which the connection is made.
maxMessageLength
public int maxMessageLength
The maximum length of message that can be sent to the queue manager.
securityUserData
public String securityUserData
A storage area for the security exit to use. Information placed here is
preserved across invocations of the security exit, and is also available to the
send and receive exits.
sendUserData
public String sendUserData
A storage area for the send exit to use. Information placed here is preserved
across invocations of the send exit, and is also available to the security and
receive exits.
receiveUserData
public String receiveUserData
A storage area for the receive exit to use. Information placed here is
preserved across invocations of the receive exit, and is also available to the
send and security exits.
connectionName
public String connectionName
The TCP/IP hostname of the machine on which the queue manager resides.
remoteUserId
public String remoteUserId
The user id used to establish the connection.
remotePassword
public String remotePassword
The password used to establish the connection.
Constructors
MQChannelDefinition
public MQChannelDefinition()
MQChannelExit
java.lang.Object
│
└─ com.ibm.mq.MQChannelExit
This class defines context information passed to the send, receive, and security
exits when they are invoked. The exitResponse member variable should be set by
the exit to indicate what action the MQSeries classes for Java should take next.
Note: This class does not apply when connecting directly to MQSeries in bindings
mode.
Variables
MQXT_CHANNEL_SEC_EXIT
public final static int MQXT_CHANNEL_SEC_EXIT
MQXT_CHANNEL_SEND_EXIT
public final static int MQXT_CHANNEL_SEND_EXIT
MQXT_CHANNEL_RCV_EXIT
public final static int MQXT_CHANNEL_RCV_EXIT
MQXR_INIT
public final static int MQXR_INIT
MQXR_TERM
public final static int MQXR_TERM
MQXR_XMIT
public final static int MQXR_XMIT
MQXR_SEC_MSG
public final static int MQXR_SEC_MSG
MQXR_INIT_SEC
public final static int MQXR_INIT_SEC
MQXCC_OK
public final static int MQXCC_OK
MQXCC_SUPPRESS_FUNCTION
public final static int MQXCC_SUPPRESS_FUNCTION
MQXCC_SEND_AND_REQUEST_SEC_MSG
public final static int MQXCC_SEND_AND_REQUEST_SEC_MSG
MQXCC_SEND_SEC_MSG
public final static int MQXCC_SEND_SEC_MSG
MQXCC_SUPPRESS_EXIT
public final static int MQXCC_SUPPRESS_EXIT
MQXCC_CLOSE_CHANNEL
public final static int MQXCC_CLOSE_CHANNEL
exitID
public int exitID
The type of exit that has been invoked. For an MQSecurityExit this is always
MQXT_CHANNEL_SEC_EXIT. For an MQSendExit this is always
MQXT_CHANNEL_SEND_EXIT, and for an MQReceiveExit this is always
MQXT_CHANNEL_RCV_EXIT.
exitReason
public int exitReason
The reason for invoking the exit. Possible values are:
MQXR_INIT
Exit initialization; called after the channel connection conditions have been
negotiated, but before any security flows have been sent.
MQXR_TERM
Exit termination; called after the disconnect flows have been sent but
before the socket connection is destroyed.
MQXR_XMIT
For a send exit indicates that data is to be transmitted to the queue
manager. For a receive exit, indicates that data has been received from
the queue manager.
MQXR_SEC_MSG
Indicates to the security exit that a security message has been received
from the queue manager.
MQXR_INIT_SEC
Indicates that the exit is to initiate the security dialog with the queue
manager.
exitResponse
public int exitResponse
Set by the exit to indicate the action that MQSeries classes for Java should
take next. Valid values are:
MQXCC_OK
Set by the security exit to indicate that security exchanges are complete.
Set by send exit to indicate that the returned data is to be transmitted to
the queue manager. Set by the receive exit to indicate that the returned
data is available for processing by the MQSeries client for Java.
MQXCC_SUPPRESS_FUNCTION
Set by the security exit to indicate that communications with the queue
manager should be shut down.
MQXCC_SEND_AND_REQUEST_SEC_MSG
Set by the security exit to indicate that the returned data is to be
transmitted to the queue manager, and that a response is expected from
the queue manager.
MQXCC_SEND_SEC_MSG
Set by the security exit to indicate that the returned data is to be
transmitted to the queue manager, and that no response is expected.
MQXCC_SUPPRESS_EXIT
Set by any exit to indicate that it should no longer be called.
MQXCC_CLOSE_CHANNEL
Set by any exit to indicate that the connection to the queue manager
should be closed.
maxSegmentLength
public int maxSegmentLength
The maximum length for any one transmission to a queue manager. If the exit
returns data that is to be sent to the queue manager, the length of the returned
data should not exceed this value.
exitUserArea
public byte exitUserArea[]
A storage area available for the exit to use. Any data placed in the
exitUserArea is preserved by MQSeries classes for Java across exit
invocations with the same exitID. (That is to say, the send, receive, and
security exits each have their own, independent, user areas.)
capabilityFlags
public static final int capabilityFlags
Indicates the capability of the queue manager. Only the
MQC.MQCF_DIST_LISTS flag is supported.
fapLevel
public static final int fapLevel
The negotiated Format and Protocol (FAP) level.
Constructors
MQChannelExit
public MQChannelExit()
MQDistributionList
java.lang.Object
│
└─ com.ibm.mq.MQManagedObject
│
└─ com.ibm.mq.MQDistributionList
A distribution list represents a set of open queues to which messages can be sent
using a single call to the put() method. (See“Distribution lists” in the MQSeries
Application Programming Guide.)
Constructors
MQDistributionList
public MQDistributionList(MQQueueManager qMgr,
MQDistributionListItem[] litems,
int openOptions,
String alternateUserId)
Throws MQException.
qMgr is the queue manager where the list is to be opened.
litems are the items to be included in the distribution list.
See "accessDistributionList" on page 107 for details of the remaining
parameters.
Methods
put
public synchronized void put(MQMessage message,
MQPutMessageOptions putMessageOptions )
Throws MQException.
Puts a message to the queues on the distribution list.
Parameters
message
An input/output parameter containing the message descriptor information
and the returned message data.
putMessageOptions
Options that control the action of MQPUT.(See “MQPutMessageOptions”
on page 90 for details.)
Throws MQException if the put fails.
getFirstDistributionListItem
public MQDistributionListItem getFirstDistributionListItem()
Returns the first item in the distribution list, or null if the list is empty.
getValidDestinationCount
public int getValidDestinationCount()
Returns the number of items in the distribution list that were opened
successfully.
getInvalidDestinationCount
public int getInvalidDestinationCount()
Returns the number of items in the distribution list that failed to open
successfully.
MQDistributionListItem
java.lang.Object
│
└─ com.ibm.mq.MQMessageTracker
│
└─ com.ibm.mq.MQDistributionListItem
Variables
completionCode
public int completionCode
The completion code resulting from the last operation on this item. If this was
the construction of an MQDistributionList, the completion code relates to the
opening of the queue. If it was a put operation, the completion code relates to
the attempt to put a message onto this queue.
The initial value is "0".
queueName
public String queueName
The name of a queue you want to use with a distribution list. This cannot be
the name of a model queue.
The initial value is "".
queueManagerName
public String queueManagerName
The name of the queue manager on which the queue is defined.
The initial value is "".
reasonCode
public int reasonCode
The reason code resulting from the last operation on this item. If this was the
construction of an MQDistributionList, the reason code relates to the opening of
the queue. If it was a put operation, the reason code relates to the attempt to
put a message onto this queue.
The initial value is "0".
Constructors
MQDistributionListItem
public MQDistributionListItem()
Construct a new MQDistributionListItem object.
MQEnvironment
java.lang.Object
│
└─ com.ibm.mq.MQEnvironment
Values set in the MQEnvironment class take effect when the MQQueueManager
constructor is called so you should set the values in the MQEnvironment class
before constructing an MQQueueManager instance.
Variables
version_notice
public final static String version_notice
The current version of MQSeries classes for Java.
securityExit
public static MQSecurityExit securityExit
A security exit allows you to customize the security flows that occur when an
attempt is made to connect to a queue manager.
To provide your own security exit, define a class that implements the
MQSecurityExit interface, and assign securityExit to an instance of that class.
Otherwise, you can leave securityExit set to null, in which case no security exit
will be called.
See also “MQSecurityExit” on page 112.
sendExit
public static MQSendExit sendExit
A send exit allows you to examine and possibly alter the data sent to a queue
manager. It is normally used in conjunction with a corresponding receive exit
at the queue manager.
To provide your own send exit, define a class that implements the MQSendExit
interface, and assign sendExit to an instance of that class. Otherwise, you can
leave sendExit set to null, in which case no send exit will be called.
See also “MQSendExit” on page 114.
receiveExit
public static MQReceiveExit receiveExit
A receive exit allows you to examine and possibly alter data received from a
queue manager. It is normally used in conjunction with a corresponding send
exit at the queue manager.
To provide your own receive exit, define a class that implements the
MQReceiveExit interface, and assign receiveExit to an instance of that class.
Otherwise, you can leave receiveExit set to null, in which case no receive exit
will be called.
See also “MQReceiveExit” on page 110.
hostname
public static String hostname
The TCP/IP hostname of the machine on which the MQSeries server resides.
If the hostname is not set, and no overriding properties are set, bindings mode
is used to connect to the local queue manager.
port
public static int port
The port to connect to. This is the port on which the MQSeries server is
listening for incoming connection requests. The default value is 1414.
channel
public static String channel
The name of the channel to connect to on the target queue manager. You
must set this member variable, or the corresponding property, before
constructing an MQQueueManager instance for use in client mode.
userID
public static String userID
Equivalent to the MQSeries environment variable MQ_USER_ID.
If a security exit is not defined for this client, the value of userID is transmitted
to the server and will be available to the server security exit when it is invoked.
The value may be used to verify the identity of the MQSeries client.
The default value is "".
password
public static String password
Equivalent to the MQSeries environment variable MQ_PASSWORD.
If a security exit is not defined for this client, the value of password is
transmitted to the server and is available to the server security exit when it is
invoked. The value may be used to verify the identity of the MQSeries client.
The default value is "".
properties
public statis java.util.Hashtable properties
A set of key/value pairs defining the MQSeries environment.
This hash table allows you to set environment properties as key/value pairs
rather than as individual variables.
Key Value
MQC.CCSID_PROPERTY Integer (Overrides MQEnvironment.CCSID.)
MQC.CHANNEL_PROPERTY String (Overrides MQEnvironment.channel.)
MQC.CONNECT_OPTIONS_PROPERTY Integer, defaults to MQC.MQCNO_NONE.
MQC.HOST_NAME_PROPERTY String (Overrides MQEnvironment.hostname.)
MQC.ORB_PROPERTY org.omg.CORBA.ORB (optional)
MQC.PASSWORD_PROPERTY String (Overrides MQEnvironment.password.)
MQC.PORT_PROPERTY Integer (Overrides MQEnvironment.port.)
MQC.RECEIVE_EXIT_PROPERTY MQReceiveExit (Overrides
MQEnvironment.receiveExit.)
MQC.SECURITY_EXIT_PROPERTY MQSecurityExit (Overrides
MQEnvironment.securityExit.)
MQC.SEND_EXIT_PROPERTY MQSendExit (Overrides MQEnvironment.sendExit.)
MQC.TRANSPORT_PROPERTY MQC.TRANSPORT_MQSERIES_BINDINGS
or
MQC.TRANSPORT_MQSERIES_CLIENT
or
MQC.TRANSPORT_VISIBROKER
or
MQC.TRANSPORT_MQSERIES (The default, which
selects bindingd or client based on the value of
"hostname".)
MQC.USER_ID_PROPERTY String (Overrides MQEnvironment.userID.)
CCSID
public static int CCSID
The CCSID used by the client.
Changing this value affects the way that the queue manager you connect to
translates information in the MQSeries headers. All data in MQSeries headers
is drawn from the invariant part of the ASCII codeset, except for the data in the
applicationIdData and the putApplicationName fields of the MQMessage class.
(See “MQMessage” on page 68.)
If you avoid using characters from the variant part of the ASCII codeset for
these two fields, you are then safe to change the CCSID from 819 to any other
ASCII codeset.
If you change the client's CCSID to be the same as that of the queue manager
to which you are connecting, you gain a performance benefit at the queue
manager because it does not attempt to translate the message headers.
The default value is 819.
Constructors
MQEnvironment
public MQEnvironment()
Methods
disableTracing
public static void disableTracing()
Turns off the MQSeries classes for Java trace facility.
enableTracing
public static void enableTracing(int level)
Turns on the MQSeries classes for Java trace facility.
Parameters
level
The level of tracing required, from 1 to 5 (5 being the most detailed)
enableTracing
public static void enableTracing(int level,
OutputStream stream)
Turns on the MQSeries classes for Java trace facility.
Parameters:
level
The level of tracing required, from 1 to 5 (5 being the most detailed)
stream
The stream to which the trace is written
MQException
java.lang.Object
│
└─ java.lang.Throwable
│
└─ java.lang.Exception
│
└─ com.ibm.mq.MQException
Variables
log
public static java.io.outputStreamWriter log
Stream to which exceptions are logged. (The default is System.err.) If you set
this to null no logging occurs.
completionCode
public int completionCode
MQSeries completion code giving rise to the error. The possible values are:
MQException.MQCC_WARNING
MQException.MQCC_FAILED
reasonCode
public int reasonCode
MQSeries reason code describing the error. For a full explanation of the
reason codes refer to the MQSeries Application Programming Reference.
exceptionSource
public Object exceptionSource
The object instance that threw the exception. You can use this as part of your
diagnostics when determining the cause of an error.
Constructors
MQException
public MQException(int completionCode,
int reasonCode,
Object source)
Construct a new MQException object.
Parameters
completionCode
The MQSeries completion code
reasonCode
The MQSeries reason code
source
The object in which the error occurred
MQGetMessageOptions
java.lang.Object
│
└─ com.ibm.mq.MQGetMessageOptions
Variables
options
public int options
Options that control the action of MQQueue.get. Any or none of the following
values can be specified. If more than one option is required the values can be
added together or combined using the bitwise OR operator.
MQC.MQGMO_NONE
MQC.MQGMO_WAIT
Wait for a message to arrive.
MQC.MQGMO_NO_WAIT
Return immediately if there is no suitable message.
MQC.MQGMO_SYNCPOINT
Get the message under syncpoint control; the message is marked as
being unavailable to other applications, but it is deleted from the queue
only when the unit of work is committed. The message is made available
again if the unit of work is backed out.
MQC.MQGMO_NO_SYNCPOINT
Get message without syncpoint control.
MQC.MQGMO_BROWSE_FIRST
Browse from start of queue.
MQC.MQGMO_BROWSE_NEXT
Browse from the current position in the queue.
MQC.MQGMO_BROWSE_MSG_UNDER_CURSOR
Browse message under browse cursor.
MQC.MQGMO_MSG_UNDER_CURSOR
Get message under browse cursor.
MQC.MQGMO_LOCK*
Lock the message that is browsed.
MQC.MQGMO_UNLOCK*
Unlock a previously locked message.
MQC.MQGMO_ACCEPT_TRUNCATED_MSG
Allow truncation of message data.
MQC.MQGMO_FAIL_IF_QUIESCING
Fail if the queue manager is quiescing.
MQC.MQGMO_CONVERT
Request the application data to be converted, to conform to the
characterSet and encoding attributes of the MQMessage, before the data
is copied into the message buffer. Because data conversion is also
applied as the data is retrieved from the message buffer, applications do
not usually set this option.
MQC.MQGMO_SYNCPOINT_IF_PERSISTENT*
Get message with syncpoint control if message is persistent.
MQC.MQGMO_MARK_SKIP_BACKOUT*
Allow a unit of work to be backed out without reinstating the message on
the queue.
Segmenting and grouping
MQSeries messages can be sent or received as a single entity, can be split
into several segments for sending and receiving, and can also be linked to
other messages in a group. Each piece of data that is sent is known as a
physical message which can be a complete logical message, or a segment of
a longer logical message. Each physical message usually has a different
MsgId. All the segments of a single logical message have the same groupId
value, and MsgSeqNumber value, but the Offset value is different for each
segment. The Offset field gives the offset of the data in the physical message
from the start of the logical message. The segments usually have different
MsgId values as they are individual physical messages. Logical messages
which form part of a group, have the same groupId value, but each message
in the group has a different MsgSeqNumber value. Messages in a group can
also be segmented.
The following options can be used for dealing with segmented or grouped
messages:
MQC.MQGMO_LOGICAL_ORDER*
Return messages in groups, and segments of logical messages, in logical
order.
MQC.MQGMO_COMPLETE_MSG*
Retrieve only complete logical messages.
MQC.MQGMO_ALL_MSGS_AVAILABLE*
Retrieve messages from a group only when all the messages in the group
are available.
MQC.MQGMO_ALL_SEGMENTS_AVAILABLE*
Retrieve the segments of a logical message only when all the segments in
the group are available.
waitInterval
public int waitInterval
The maximum time (in milliseconds) that an MQQueue.get call waits for a
suitable message to arrive (used in conjunction with MQC.MQGMO_WAIT). A
value of MQC.MQWI_UNLIMITED indicates that an unlimited wait is required.
resolvedQueueName
public String resolvedQueueName
This is an output field set by the queue manager to the local name of the
queue from which the message was retrieved. This will be different from the
name used to open the queue if an alias queue or model queue was opened.
matchOptions*
public int matchOptions
Selection criteria that determine which message is retrieved. The following
match options can be set:
MQC.MQMO_MATCH_MSG_ID
Message id to be matched
MQC.MQMO_MATCH_CORREL_ID
Correlation id to be matched
MQC.MQMO_MATCH_GROUP_ID
Group id to be matched
MQC.MQMO_MATCH_MSG_SEQ_NUMBER
Match message sequence number
MQC.MQMO_NONE
No matching required
groupStatus*
public char groupStatus
This is an output field which indicates whether the retrieved message is in a
group, and if it is, whether it is the last in the group. Possible values are:
MQC.MQGS_NOT_IN_GROUP
Message is not in a group.
MQC.MQGS_MSG_IN_GROUP
Message is in a group, but is not the last in the group.
MQC.MQGS_LAST_MSG_IN_GROUP
Message is the last in the group. This is also the value returned if the
group consists of only one message.
segmentStatus*
public char segmentStatus
This is an output field that indicates whether the retrieved message is a
segment of a logical message. If the message is a segment, the flag indicates
whether or not it is the last segment. Possible values are:
MQC.MQSS_NOT_A_SEGMENT
Message is not a segment.
MQC.MQSS_SEGMENT
Message is a segment, but is not the last segment of the logical message.
MQC.MQSS_LAST_SEGMENT
Message is the last segment of the logical message. This is also the
value returned if the logical message consists of only one segment.
segmentation*
public char segmentation
This is an output field that indicates whether or not segmentation is allowed for
the retrieved message is a segment of a logical message. Possible values
are:
MQC.MQSEG_INHIBITED
Segmentation not allowed.
MQC.MQSEG_ALLOWED
Segmentation allowed.
Constructors
MQGetMessageOptions
public MQGetMessageOptions()
Construct a new MQGetMessageOptions object with options set to
MQC.MQGMO_NO_WAIT, a wait interval of zero, and a blank resolved queue
name.
MQManagedObject
java.lang.Object
│
└─ com.ibm.mq.MQManagedObject
Variables
alternateUserId
public String alternateUserId
The alternate user id specified (if any) when this resource was opened.
Setting this attribute has no effect.
name
public String name
The name of this resource (either the name supplied on the access method, or
the name allocated by the queue manager for a dynamic queue). Setting this
attribute has no effect.
openOptions
public int openOptions
The options specified when this resource was opened. Setting this attribute
has no effect.
isOpen
public boolean isOpen
Indicates whether this resource is currently open. Setting this attribute has no
effect.
connectionReference
public MQQueueManager connectionReference
The queue manager to which this resource belongs. Setting this attribute has
no effect.
closeOptions
public int closeOptions
Set this attribute to control the way the resource is closed. The default value is
MQC.MQCO_NONE, and this is the only permissible value for all resources
other than permanent dynamic queues. For these queues, the following
additional values are permissible:
MQC.MQCO_DELETE
Delete the queue if there are no messages.
MQC.MQCO_DELETE_PURGE
Delete the queue, purging any messages on it.
Constructors
MQManagedObject
protected MQManagedObject()
Constructor method.
Methods
getDescription
public String getDescription()
Throws IOException.
Return the description of this resource as held at the queue manager.
If this method is called after the resource has been closed, an IOException is
thrown.
inquire
public void inquire(int selectors[],
int intAttrs[],
byte charAttrs[])
Throws MQException.
Returns an array of integers and a set of character strings containing the
attributes of an object (queue, process or queue manager).
The attributes to be queried are specified in the selectors array. Refer to the
MQSeries Application Programming Reference for details of the permissible
selectors and their corresponding integer values.
Note that many of the more common attribute values can be queried using the
getXXX() methods defined in MQManagedObject, MQQueue,
MQQueueManager, and MQProcess.
Parameters
selectors
Integer array identifying the attributes with values to be inquired on.
intAttrs
The array in which the integer attribute values are returned. Integer
attribute values are returned in the same order as the integer attribute
selectors in the selectors array.
charAttrs
The buffer in which the character attributes are returned, concatenated.
Character attributes are returned in the same order as the character
attribute selectors in the selectors array. The length of each attribute
string is fixed for each attribute.
Throws MQException if the inquire fails.
isOpen
public Boolean isOpen()
Returns the value of the isOpen variable.
set
public synchronized void set(int selectors[],
int intAttrs[],
byte charAttrs[])
Throws MQException.
Set the attributes defined in the selector's vector.
The attributes to be set are specified in the selectors array. Refer to the
MQSeries Application Programming Reference for details of the permissible
selectors and their corresponding integer values.
Note that some queue attribute values can be set using the setXXX() methods
defined in MQQueue.
Parameters
selectors
Integer array identifying the attributes with values to be set.
intAttrs
The array of integer attribute values to be set. These values must be in
the same order as the integer attribute selectors in the selectors array.
charAttrs
The buffer in which the character attributes to be set are concatenated.
These values must be in the same order as the character attribute
selectors in the selectors array. The length of each character attribute is
fixed.
Throws MQException if the set fails.
close
public synchronized void close()
Throws MQException.
Close the object. No further operations against this resource are permitted after
this method has been called. The behavior of the close method may be altered
by setting the closeOptions attribute.
Throws MQException if the MQSeries call fails
MQMessage
java.lang.Object
│
└─ com.ibm.mq.MQMessage
MQMessage represents both the message descriptor and the data for an MQSeries
message. There is group of readXXX methods for reading data from a message,
and a group of writeXXX data for writing data into a message. The format of
numbers and strings used by these read and write methods can be controlled by
the encoding and characterSet member variables. The remaining member
variables contain control information that accompanies the application message
data when a message travels between sending and receiving applications. The
application can set values into the member variable before putting a message to a
queue and can read values after retrieving a message from a queue.
Variables
report
public int report
A report is a message about another message. This member variable enables
the application sending the original message to specify which report messages
are required, whether the application message data is to be included in them,
and also how the message and correlation identifiers in the report or reply are
to be set. Any, all or none of the following report types can be requested:
Exception
Expiration
Confirm on arrival
Confirm on delivery
For each type, only one of the three corresponding values below should be
specified, depending on whether the application message data is to be
included in the report message.
Note: Values marked with ** in the following list are not supported by MVS
queue managers and should not be used if your application is likely to access
an MVS queue manager, regardless of the platform on which the application is
running.
The valid values are:
MQC.MQRO_EXCEPTION
MQC.MQRO_EXCEPTION_WITH_DATA
MQC.MQRO_EXCEPTION_WITH_FULL_DATA**
MQC.MQRO_EXPIRATION
MQC.MQRO_EXPIRATION_WITH_DATA
MQC.MQRO_EXPIRATION_WITH_FULL_DATA**
MQC.MQRO_COA
MQC.MQRO_COA_WITH_DATA
MQC.MQRO_COA_WITH_FULL_DATA**
MQC.MQRO_COD
MQC.MQRO_COD_WITH_DATA
MQC.MQRO_COD_WITH_FULL_DATA**
You can specify one of the following to control how the message Id is
generated for the report or reply message:
MQC.MQRO_NEW_MSG_ID
MQC.MQRO_PASS_MSG_ID
You can specify one of the following to control how the correlation Id of the
report or reply message is to be set:
MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID
MQC.MQRO_PASS_CORREL_ID
You can specify one of the following to control the disposition of the original
message when it cannot be delivered to the destination queue:
MQC.MQRO_DEAD_LETTER_Q
MQC.MQRO_DISCARD_MSG **
If no report options are specified, the default is:
MQC.MQRO_NEW_MSG_ID |
MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID |
MQC.MQRO_DEAD_LETTER_Q
You can specify one or both of the following to request that the receiving
application send a positive action or negative action report message.
MQRO_PAN
MQRO_NAN
messageType
public int messageType
Indicates the type of the message. The following values are currently defined
by the system:
MQC.MQMT_DATAGRAM
MQC.MQMT_REQUEST
MQC.MQMT_REPLY
MQC.MQMT_REPORT
Application-defined values can also be used. These should be in the range
MQC.MQMT_APPL_FIRST to MQC.MQMT_APPL_LAST.
The default value of this field is MQC.MQMT_DATAGRAM.
expiry
public int expiry
An expiry time expressed in tenths of a second, set by the application that puts
the message. After a message's expiry time has elapsed, it is eligible to be
discarded by the queue manager. If the message specified one of the
MQC.MQRO_EXPIRATION flags, a report is generated when the message is
discarded.
The default value is MQC.MQEI_UNLIMITED, meaning that the message never
expires.
feedback
public int feedback
This is used with a message of type MQC.MQMT_REPORT to indicate the
nature of the report. The following feedback codes are defined by the system:
MQC.MQFB_EXPIRATION
MQC.MQFB_COA
MQC.MQFB_COD
MQC.MQFB_QUIT
MQC.MQFB_PAN
MQC.MQFB_NAN
MQC.MQFB_DATA_LENGTH_ZERO
MQC.MQFB_DATA_LENGTH_NEGATIVE
MQC.MQFB_DATA_LENGTH_TOO_BIG
MQC.MQFB_BUFFER_OVERFLOW
MQC.MQFB_LENGTH_OFF_BY_ONE
MQC.MQFB_IIH_ERROR
Application-defined feedback values in the range MQC.MQFB_APPL_FIRST to
MQC.MQFB_APPL_LAST can also be used.
The default value of this field is MQC.MQFB_NONE, indicating that no
feedback is provided.
encoding
public int encoding
This member variable specifies the representation used for numeric values in
the application message data; this applies to binary, packed decimal, and
floating point data. The behavior of the read and write methods for these
numeric formats is altered accordingly.
The following encodings are defined for binary integers:
MQC.MQENC_INTEGER_NORMAL
Big-endian integers, as in Java
MQC.MQENC_INTEGER_REVERSED
Little-endian integers, as used by PCs
The following encodings are defined for packed-decimal integers:
MQC.MQENC_DECIMAL_NORMAL
Big-endian packed-decimal, as used by System/390
MQC.MQENC_DECIMAL_REVERSED
Little-endian packed-decimal
The following encodings are defined for floating-point numbers:
MQC.MQENC_FLOAT_IEEE_NORMAL
Big-endian IEEE floats, as in Java
MQC.MQENC_FLOAT_IEEE_REVERSED
Little-endian IEEE floats, as used by PCs
MQC.MQENC_FLOAT_S390
System/390 format floating points
A value for the encoding field should be constructed by adding together one
value from each of these three sections (or using the bitwise OR operator).
The default value is:
MQC.MQENC_INTEGER_NORMAL |
MQC.MQENC_DECIMAL_NORMAL |
MQC.MQENC_FLOAT_IEEE_NORMAL
For convenience, this value is also represented by MQC.MQENC_NATIVE.
This setting causes writeInt() to write a big-endian integer, and readInt() to read
a big-endian integer. If the flag MQC.MQENC_INTEGER_REVERSED flag
had been set instead, writeInt() would write a little-endian integer, and readInt()
would read a little-endian integer.
Note that a loss in precision can occur when converting from IEEE format
floating points to System/390 format floating points.
characterSet
public int characterSet
This specifies the coded character set identifier of character data in the
application message data. The behavior of the readString, readLine and
writeString methods is altered accordingly.
The default value for this field is MQC.MQCCSI_Q_MGR, which specifies that
character data in the application message data is in the queue manager's
character set. The additional character set values shown in Table 6 are
supported.
format
public String format
A format name used by the sender of the message to indicate to the receiver
the nature of the data in the message. You can use your own format names,
but names beginning with the letters "MQ" have meanings that are defined by
the queue manager. The queue manager built-in formats are:
MQC.MQFMT_NONE
No format name
MQC.MQFMT_ADMIN
Command server request/reply message
MQC.MQFMT_COMMAND_1
Type 1 command reply message
MQC.MQFMT_COMMAND_2
Type 2 command reply message
MQC.MQFMT_DEAD_LETTER_HEADER
Dead letter header
MQC.MQFMT_EVENT
Event message
MQC.MQFMT_PCF
User-defined message in programmable command format
MQC.MQFMT_STRING
Message consisting entirely of characters
MQC.MQFMT_TRIGGER
Trigger message
MQC.MQFMT_XMIT_Q_HEADER
Transmission queue header
The default value is MQC.MQFMT_NONE.
priority
public int priority
The message priority. The special value MQC.MQPRI_PRIORITY_AS_Q_DEF
can also be set in outbound messages, in which case the priority for the
message is taken from the default priority attribute of the destination queue.
The default value is MQC.MQPRI_PRIORITY_AS_Q_DEF.
persistence
public int persistence
Message persistence. The following values are defined:
MQC.MQPER_PERSISTENT
MQC.MQPER_NOT_PERSISTENT
MQC.MQPER_PERSISTENCE_AS_Q_DEF
The default value is MQC.MQPER_PERSISTENCE_AS_Q_DEF, which
indicates that the persistence for the message should be taken from the default
persistence attribute of the destination queue.
messageId
public byte messageId[]
For an MQQueue.get() call, this field specifies the message identifier of the
message to be retrieved. Normally the queue manager returns the first
message with a message identifier and correlation identifier match those
specified. The special value MQC.MQMI_NONE allows any message identifier
to match.
For an MQQueue.put() call, this specifies the message identifier to use. If
MQC.MQMI_NONE is specified,the queue manager generates a unique
message identifier when the message is put. The value of this member
variable is updated after the put to indicate the message identifier that was
used.
The default value is MQC.MQMI_NONE.
correlationId
public byte correlationId[]
For an MQQueue.get() call, this field specifies the correlation identifier of the
message to be retrieved. Normally the queue manager returns the first
message with a message identifier and correlation identifier that match those
specified. The special value MQC.MQCI_NONE allows any correlation
identifier to match.
For an MQQueue.put()() call, this specifies the correlation identifier to use.
The default value is MQC.MQCI_NONE.
backoutCount
public int backoutCount
A count of the number of times the message has previously been returned by
an MQQueue.get() call as part of a unit of work, and subsequently backed out.
The default value is zero.
replyToQueueName
public String replyToQueueName
The name of the message queue to which the application that issued the get
request for the message should send MQC.MQMT_REPLY and
MQC.MQMT_REPORT messages.
The default value is "".
replyToQueueManagerName
public String replyToQueueManagerName
The name of the queue manager to which reply or report messages should be
sent.
The default value is "".
If the value is "" on an MQQueue.put() call, the QueueManager fills in the
value.
userId
public String userId
Part of the identity context of the message; it identifies the user that originated
this message.
The default value is "".
accountingToken
public byte accountingToken[]
Part of the identity context of the message; it allows an application to cause
work done as a result of the message to be appropriately charged.
The default value is "MQC.MQACT_NONE".
applicationIdData
public String applicationIdData
Part of the identity context of the message; it is information that is defined by
the application suite, and can be used to provide additional information about
the message or its originator.
The default value is "".
putApplicationType
public int putApplicationType
The type of application that put the message. This may be a system or user
defined value. The following values are defined by the system:
MQC.MQAT_AIX
MQC.MQAT_CICS
MQC.MQAT_DOS
MQC.MQAT_IMS
MQC.MQAT_MVS
MQC.MQAT_OS2
MQC.MQAT_OS400
MQC.MQAT_QMGR
MQC.MQAT_UNIX
MQC.MQAT_WINDOWS
MQC.MQAT_JAVA
The default value is the special value MQC.MQAT_NO_CONTEXT, which
indicates that no context information is present in the message.
putApplicationName
public String putApplicationName
The name of the application that put the message. The default value is "".
putDateTime
public GregorianCalendar putDateTime
The time and date that the message was put.
applicationOriginData
public String applicationOriginData
Information defined by the application that can be used to provide additional
information about the origin of the message.
The default value is "".
groupId
public byte[] groupId
A byte string that identifies the message group to which the physical message
belongs.
The default value is "MQC.MQGI_NONE".
messageSequenceNumber
public int messageSequenceNumber
The sequence number of a logical message within a group.
offset
public int offset
In a segmented message, the offset of data in a physical message from the
start of a logical message.
messageFlags
public int messageFlags
Flags controlling the segmentation and status of a message.
originalLength
public int originalLength
The original length of a segmented message.
Constructors
MQMessage
public MQMessage()
Create a new message with default message descriptor information and an
empty message buffer.
Methods
getTotalMessageLength
public int getTotalMessageLength()
The total number of bytes in the message as stored on the message queue
from which this message was retrieved (or attempted to be retrieved). When an
MQQueue.get() method fails with a message-truncated error code, this method
tells you the total size of the message on the queue.
See also "MQQueue.get" on page 94.
getMessageLength
public int getMessageLength
Throws IOException.
The number of bytes of message data in this MQMessage object.
getDataLength
public int getDataLength()
Throws MQException.
The number of bytes of message data remaining to be read.
seek
public void seek(int pos)
Throws IOException.
Move the cursor to the absolute position in the message buffer given by pos.
Subsequent reads and writes will act at this position in the buffer.
Throws EOFException if pos is outside the message data length.
setDataOffset
public void setDataOffset(int offset)
Throws IOException.
Move the cursor to the absolute position in the message buffer. This method
is a synonym for seek(), and is provided for cross-language compatibility with
the other MQSeries APIs.
getDataOffset
public int getDataOffset()
Throws IOException.
Return the current cursor position within the message data (the point at which
read and write operations take effect).
clearMessage
public void clearMessage()
Throws IOException.
Discard any data in the message buffer and set the data offset back to zero.
getVersion
public int getVersion()
Returns the version of the structure in use.
resizeBuffer
public void resizeBuffer(int size)
Throws IOException.
A hint to the MQMessage class about the size of buffer that may be required
for subsequent get operations. If the message currently contains message
data, and the new size is less than the current size, the message data is
truncated.
readBoolean
public boolean readBoolean()
Throws IOException.
Read a (signed) byte from the current position in the message buffer.
readChar
public char readChar()
Throws IOException, EOFException.
Read a Unicode character from the current position in the message buffer.
readDouble
public double readDouble()
Throws IOException, EOFException.
Read a double from the current position in the message buffer. The behavior
of this method is determined by the value of the encoding member variable.
readUnsignedShort
public int readUnsignedShort()
Throws IOException, EOFException.
Read an unsigned short from the current position in the message buffer. The
behavior of this method is determined by the value of the encoding member
variable.
A value of MQC.MQENC_INTEGER_NORMAL reads a big-endian unsigned
short, a value of MQC.MQENC_INTEGER_REVERSED reads a little-endian
unsigned short.
readUInt2
public int readUInt2()
Throws IOException, EOFException.
Synonym for readUnsignedShort(), provided for cross-language MQSeries API
compatibility.
readString
public String readString(int length)
Throws IOException, EOFException.
Read a string in the codeset identified by the characterSet member variable,
and convert it into Unicode.
Parameters:
length The number of characters to read (which may differ from the
number of bytes according to the codeset, because some codesets
use more than one byte per character).
readDecimal2
public short readDecimal2()
Throws IOException, EOFException.
Read a 2-byte packed decimal number (-999..999). The behavior of this
method is controlled by the value of the encoding member variable. A value of
MQC.MQENC_DECIMAL_NORMAL reads a big-endian packed decimal
number, and a value of MQC.MQENC_DECIMAL_REVERSED reads a
little-endian packed decimal number.
readDecimal4
public int readDecimal4()
Throws IOException, EOFException.
Read a 4-byte packed decimal number (-9999999..9999999). The behavior of
this method is controlled by the value of the encoding member variable. A
value of MQC.MQENC_DECIMAL_NORMAL reads a big-endian packed
decimal number, and a value of MQC.MQENC_DECIMAL_REVERSED reads a
little-endian packed decimal number.
readDecimal8
public long readDecimal8()
Throws IOException, EOFException.
writeByte
public void writeByte(int v)
Throws IOException.
Write a byte into the message buffer at the current position.
writeBytes
public void writeBytes(String s)
Throws IOException.
Write a string as a sequence of bytes into the message buffer at the current
position.
writeChar
public void writeChar(int v)
Throws IOException.
Write a Unicode character into the message buffer at the current position.
writeChars
public void writeChars(String s)
Throws IOException.
Write a string as a sequence of Unicode characters into the message buffer at
the current position.
writeDouble
public void writeDouble(double v)
Throws IOException
Write a double into the message buffer at the current position. The behavior of
this method is determined by the value of the encoding member variable.
Values of MQC.MQENC_FLOAT_IEEE_NORMAL and
MQC.MQENC_FLOAT_IEEE_REVERSED write IEEE standard floats in
Big-endian and Little-endian formats respectively.
A value of MQC.MQENC_FLOAT_S390 writes a System/390 format floating
point number. Note that the range of IEEE doubles is greater than the range
of S/390 double precision floating point numbers, and so very large numbers
cannot be converted.
writeFloat
public void writeFloat(float v)
Throws IOException.
Write a float into the message buffer at the current position. The behavior of
this method is determined by the value of the encoding member variable.
Values of MQC.MQENC_FLOAT_IEEE_NORMAL and
MQC.MQENC_FLOAT_IEEE_REVERSED write IEEE standard floats in
big-endian and little-endian formats respectively.
A value of MQC.MQENC_FLOAT_S390 will write a System/390 format floating
point number.
writeInt
public void writeInt(int v)
Throws IOException.
Write an integer into the message buffer at the current position. The behavior
of this method is determined by the value of the encoding member variable.
A value of MQC.MQENC_INTEGER_NORMAL writes a big-endian integer, a
value of MQC.MQENC_INTEGER_REVERSED writes a little-endian integer.
writeInt4
public void writeInt4(int v)
Throws IOException.
Synonym for writeInt(), provided for cross-language MQSeries API
compatibility.
writeLong
public void writeLong(long v)
Throws IOException.
Write a long into the message buffer at the current position. The behavior of
this method is determined by the value of the encoding member variable.
A value of MQC.MQENC_INTEGER_NORMAL writes a big-endian long, a
value of MQC.MQENC_INTEGER_REVERSED writes a little-endian long.
writeInt8
public void writeInt8(long v)
Throws IOException.
Synonym for writeLong(), provided for cross-language MQSeries API
compatibility.
writeObject
public void writeObject(Object obj)
Throws IOException.
Write the specified object to the message buffer. The class of the object, the
signature of the class, and the values of the non-transient and non-static fields
of the class and all its supertypes are all written.
writeShort
public void writeShort(int v)
Throws IOException.
Write a short into the message buffer at the current position. The behavior of
this method is determined by the value of the encoding member variable.
A value of MQC.MQENC_INTEGER_NORMAL writes a big-endian short, a
value of MQC.MQENC_INTEGER_REVERSED writes a little-endian short.
writeInt2
public void writeInt2(int v)
Throws IOException.
Synonym for writeShort(), provided for cross-language MQSeries API
compatibility.
writeDecimal2
public void writeDecimal2(short v)
Throws IOException.
Write a 2-byte packed decimal format number into the message buffer at the
current position. The behavior of this method is determined by the value of the
encoding member variable.
A value of MQC.MQENC_DECIMAL_NORMAL writes a Big-endian packed
decimal, a value of MQC.MQENC_DECIMAL_REVERSED writes a
Little-endian packed decimal.
Parameters
v can be in the range -999 to 999.
writeDecimal4
public void writeDecimal4(int v)
Throws IOException.
Write a 4-byte packed decimal format number into the message buffer at the
current position. The behavior of this method is determined by the value of the
encoding member variable.
A value of MQC.MQENC_DECIMAL_NORMAL writes a big-endian packed
decimal, a value of MQC.MQENC_DECIMAL_REVERSED writes a little-endian
packed decimal.
Parameters
v can be in the range -9999999 to 9999999.
writeDecimal8
public void writeDecimal8(long v)
Throws IOException.
Write an 8-byte packed decimal format number into the message buffer at the
current position. The behavior of this method is determined by the value of the
encoding member variable.
A value of MQC.MQENC_DECIMAL_NORMAL writes a big-endian packed
decimal, a value of MQC.MQENC_DECIMAL_REVERSED writes a little-endian
packed decimal.
Parameters:
v can be in the range -999999999999999 to 999999999999999.
writeUTF
public void writeUTF(String str)
Throws IOException.
Write a string in UTF format into the message buffer at the current position.
writeString
public void writeStringString(str)
Throws IOException.
Write a string into the message buffer at the current position, converting it to
the codeset identified by the characterSet member variable.
MQMessageTracker
java.lang.Object
│
└─ com.ibm.mq.MQMessageTracker
Variables
feedback
public int feedback
This is used with a message of type MQC.MQMT_REPORT to indicate the
nature of the report. The following feedback codes are defined by the system:
MQC.MQFB_EXPIRATION
MQC.MQFB_COA
MQC.MQFB_COD
MQC.MQFB_QUIT
MQC.MQFB_PAN
MQC.MQFB_NAN
MQC.MQFB_DATA_LENGTH_ZERO
MQC.MQFB_DATA_LENGTH_NEGATIVE
MQC.MQFB_DATA_LENGTH_TOO_BIG
MQC.MQFB_BUFFER_OVERFLOW
MQC.MQFB_LENGTH_OFF_BY_ONE
MQC.MQFB_IIH_ERROR
Application defined feedback values in the range MQC.MQFB_APPL_FIRST to
MQC.MQFB_APPL_LAST can also be used.
The default value of this field is MQC.MQFB_NONE, indicating that no
feedback is provided.
messageId
public byte messageId[]
This specifies the message identifier to use when the message is put. If
MQC.MQMI_NONE is specified, the queue manager generates a unique
message identifier when the message is put. The value of this member
variable is updated after the put to indicate the message identifier that was
used.
The default value is MQC.MQMI_NONE.
correlationId
public byte correlationId[]
This specifies the correlation identifier to use when the message is put.
The default value is MQC.MQCI_NONE.
accountingToken
public byte accountingToken[]
This is part of the identity context of the message. It allows an application to
cause work done as a result of the message to be appropriately charged.
The default value is "MQC.MQACT_NONE".
groupId
public byte[] groupId
A byte string that identifies the message group to which the physical message
belongs.
The default value is "MQC.MQGI_NONE".
MQProcess
java.lang.Object
│
└─ com.ibm.mq.MQManagedObject
│
└─ com.ibm.mq.MQProcess
Constructors
MQProcess
public MQProcess(MQQueueManager qMgr,
String processName,
int openOptions,
String queueManagerName,
String alternateUserId)
Throws MQException.
Access a process on the queue manager qMgr. See accessProcess in the
“MQQueueManager” on page 101 for details of the remaining parameters.
Methods
getApplicationId
public String getApplicationId()
A character string that identifies the application to be started. This information
is for use by a trigger monitor application that processes messages on the
initiation queue; the information is sent to the initiation queue as part of the
trigger message.
Throws MQException if you call this method after you have closed the process.
getApplicationType
public int getApplicationType() throws MQException (see page 59)
This identifies the nature of the program to be started in response to the
receipt of a trigger message. The application type can take any value, but the
following values are recommended for standard types:
MQC.MQAT_AIX
MQC.MQAT_CICS
MQC.MQAT_DOS
MQC.MQAT_IMS
MQC.MQAT_MVS
MQC.MQAT_OS2
MQC.MQAT_OS400
MQC.MQAT_UNIX
MQC.MQAT_WINDOWS
MQC.MQAT_WINDOWS_NT
MQPutMessageOptions
java.lang.Object
│
└─ com.ibm.mq.MQPutMessageOptions
Variables
options
public int options
Options that control the action of MQQueue.put. Any or none of the following
values can be specified. If more than one option is required the values can be
added together or combined using the bitwise OR operator.
MQC.MQPMO_SYNCPOINT
Put a message with syncpoint control. The message is not visible outside
the unit of work until the unit of work is committed. If the unit of work is
backed out, the message is deleted.
MQC.MQPMO_NO_SYNCPOINT
Put a message without syncpoint control.
MQC.MQPMO_NO_CONTEXT
No context is to be associated with the message.
MQC.MQPMO_DEFAULT_CONTEXT
Associate default context with the message.
MQC.MQPMO_SET_IDENTITY_CONTEXT
Set identity context from the application.
MQC.MQPMO_SET_ALL_CONTEXT
Set all context from the application.
MQC.MQPMO_FAIL_IF_QUIESCING
Fail if the queue manager is quiescing.
MQC.MQPMO_NEW_MSG_ID*
Generate a new message id for each sent message.
MQC.MQPMO_NEW_CORREL_ID*
Generate a new correlation id for each sent message.
MQC.MQPMO_LOGICAL_ORDER*
Put logical messages and segments in message groups into their logical
order.
MQC.MQPMO_NONE
No options specified. Do not use in conjunction with other options.
MQC.MQPMO_PASS_IDENTITY_CONTEXT
Pass identity context from an input queue handle.
MQC.MQPMO_PASS_ALL_CONTEXT
Pass all context from an input queue handle.
MQC.MQPMO_ALTERNATE_USER_AUTHORITY
Validate with specified user identifier.
contextReference
public MQQueue ContextReference
This is an input field which indicates the source of the context information.
If the options field includes MQC.MQPMO_PASS_IDENTITY_CONTEXT, or
MQC.MQPMO_PASS_ALL_CONTEXT, set this field to refer to the MQQueue
from which the context information should be taken.
The initial value of this field is null.
recordFields *
public int recordFields
Flags indicating which fields are to be customized on a per-queue basis when
putting a message to a distribution list. One or more of the following flags can
be specified:
MQC.MQPMRF_MSG_ID
Use the messageId attribute in the MQDistributionListItem.
MQC.MQPMRF_CORREL_ID
Use the correlationId attribute in the MQDistributionListItem.
MQC.MQPMRF_GROUP_ID
Use the groupId attribute in the MQDistributionListItem.
MQC.MQPMRF_FEEDBACK
Use the feedback attribute in the MQDistributionListItem.
MQC.MQPMRF_ACCOUNTING_TOKEN
Use the accountingToken attribute in the MQDistributionListItem.
The special value MQC.MQPMRF_NONE indicates that no fields are to be
customized.
resolvedQueueName.
public String resolvedQueueName
This is an output field that is set by the queue manager to the name of the
queue on which the message is placed. This may be different from the name
used to open the queue if the opened queue was an alias or model queue.
resolvedQueueManagerName
public String resolvedQueueManagerName
This is an output field set by the queue manager to the name of the queue
manager that owns the queue specified by the remote queue name. This may
be different from the name of the queue manager from which the queue was
accessed if the queue is a remote queue.
knownDestCount *
public int knownDestCount
This is an output field set by the queue manager to the number of messages
that the current call has sent successfully to queues that resolve to local
queues. This field is also set when opening a single queue that is not part of a
distribution list.
unknownDestCount *
public int unknownDestCount
This is an output field set by the queue manager to the number of messages
that the current call has sent successfully to queues that resolve to remote
queues. This field is also set when opening a single queue that is not part of a
distribution list.
invalidDestCount *
public int invalidDestCount
This is an output field set by the queue manager to the number of messages
that could not be sent to queues in a distribution list. The count includes
queues that failed to open as well as queues that were opened successfully,
but for which the put operation failed. This field is also set when opening a
single queue that is not part of a distribution list.
Constructors
MQPutMessageOptions
public MQPutMessageOptions()
Construct a new MQPutMessageOptions object with no options set, and a
blank resolvedQueueName and resolvedQueueManagerName.
MQQueue
java.lang.Object
│
└─ com.ibm.mq.MQManagedObject
│
└─ com.ibm.mq.MQQueue
MQQueue provides inquire, set, put, and get operations for MQSeries queues. The
inquire and set capabilities are inherited from MQ.MQManagedObject
Constructors
MQQueue:
public MQQueue(MQQueueManager qMgr, String queueName, int openOptions,
String queueManagerName, String dynamicQueueName,
Throws MQException.
Access a queue on the queue manager qMgr.
See "MQQueueManager.accessQueue" on page 104 for details of the
remaining parameters.
Methods
get
public synchronized void get(MQMessage message,
MQGetMessageOptions getMessageOptions,
int MaxMsgSize)
Throws MQException.
Retrieves a message from the queue, up to a maximum specified message
size.
This method takes an MQMessage object as a parameter. It uses some of the
fields in the object as input parameters - in particular the messageId and
correlationId, so it is important to ensure that these are set as required. (See
the MQMessage documentation for details.)
If the get fails the MQMessage object is unchanged. If it succeeds the
message descriptor (member variables) and message data portions of the
MQMessage are completely replaced with the message descriptor and
message data from the incoming message.
Note that all calls to MQSeries from a given MQQueueManager are
synchronous. Therefore, if you perform a get with wait, all other threads using
the same MQQueueManager are blocked from making further MQSeries calls
until the get completes. If you need multiple threads to access MQSeries
simultaneously, each thread must create its own MQQueueManager object.
Parameters
message
An input/output parameter containing the message descriptor information
and the returned message data.
getMessageOptions
Options controlling the action of the get. (See the MQGetMessageOptions
documentation for details.)
MaxMsgSize
The largest message this call will be able to receive. If the message on
the queue is larger than this size, one of two things can occur:
1. If the MQC.MQGMO_ACCEPT_TRUNCATED_MSG flag is set in the
options member variable of the MQGetMessageOptions object, then
the message is filled with as much of the message data as will fit in
the specified buffer size, and an exception is thrown with completion
code MQException.MQCC_WARNING and reason code
MQException.MQRC_TRUNCATED_MSG_ACCEPTED.
2. If the MQC.MQGMO_ACCEPT_TRUNCATED_MSG flag is not set
then the message is left on the queue and an MQException is raised
with completion code MQException.MQCC_FAILED and reason code
MQException.MQRC_TRUNCATED_MSG_FAILED.
Throws MQException if the get fails.
get
public synchronized void get MQMessage message,
MQGetMessageOptions getMessageOptions)
Throws MQException.
Retrieves a message from the queue, regardless of the size of the message.
For large messages, the get method may have to issue two calls to MQSeries
on your behalf, one to establish the required buffer size and one to get the
message data itself.
This method takes an MQMessage object as a parameter. It uses some of the
fields in the object as input parameters - in particular the messageId and
correlationId, so it is important to ensure that these are set as required. (See
the MQMessage documentation for details.)
If the get fails, the MQMessage object is unchanged. If it succeeds, the
message descriptor (member variables) and message data portions of the
MQMessage are completely replaced with the message descriptor and
message data from the incoming message.
Note that all calls to MQSeries from a given MQQueueManager are
synchronous. Therefore, if you perform a get with wait, all other threads using
the same MQQueueManager are blocked from making further MQSeries calls
until the get completes. If you need multiple threads to access MQSeries
simultaneously, each thread must create its own MQQueueManager object.
Parameters
message
An input/output parameter containing the message descriptor information
and the returned message data.
getMessageOptions
Options controlling the action of the get. (See “MQGetMessageOptions”
on page 61 for details.)
Throws MQException if the get fails.
get
public synchronized void get(MQMessage message)
This is a simplified version of the get method previously described.
Parameters
MQmessage
An input/output parameter containing the message descriptor information
and the returned message data.
This method uses a default instance of MQGetMessageOptions to do the get.
The message option used is MQGMO_NOWAIT.
put
public synchronized void put(MQMessage message,
MQPutMessageOptions putMessageOptions)
Throws MQException.
Places a message onto the queue.
This method takes an MQMessage object as a parameter. The message
descriptor properties of this object may be altered as a result of this method.
The values they have immediately after the completion of this method are the
values that were put onto the MQSeries queue.
Modifications to the MQMessage object after the put has completed do not
affect the actual message on the MQSeries queue.
Note that performing a put updates the messageId and correlationId, which
must be taken into consideration when making further calls to put/get using the
same MQMessage object. Also note that calling put does not clear the
message data, so:
msg.writeString("a");
q.put(msg,pmo);
msg.writeString("b");
q.put(msg,pmo);
puts two messages. The first contains "a" and the second "ab".
Parameters
message
Message Buffer containing the Message Descriptor data and message to
be sent.
putMessageOptions
Options controlling the action of the put. (See the MQPutMessageOptions
documentation for details.)
Throws MQException if the put fails.
put
public synchronized void put(MQMessage message)
This is a simplified version of the put method previously described.
Parameters
MQmessage
Message Buffer containing the Message Descriptor data and message to
be sent.
This method uses a default instance of MQPutMessageOptions to do the put.
Note: All the following methods throw MQException if you call the method after
you have closed the queue.
getCreationDateTime
public GregorianCalander getCreationDateTime()
Throws MQException.
The date and time that this queue was created.
getQueueType
public int getQueueType()
Throws MQException.
Returns
The type of this queue with one of the following values:
MQC.MQQT_ALIAS
MQC.MQQT_LOCAL
MQC.MQQT_MODEL
MQC.MQQT_REMOTE
MQC.MQQT_CLUSTER
getCurrentDepth
public int getCurrentDepth()
Throws MQException.
Get the number of messages currently on the queue. This value is
incremented during a put call, and during backout of a get call. It is
decremented during a non-browse get and during backout of a put call.
getDefinitionType
public int getDefinitionType()
Throws MQException.
Indicates how the queue was defined.
Returns
One of the following:
MQC.MQQDT_PREDEFINED
MQC.MQQDT_PERMANENT_DYNAMIC
MQC.MQQDT_TEMPORARY_DYNAMIC
getMaximumDepth
public int getMaximumDepth()
Throws MQException.
The maximum number of messages that can exist on the queue at any one
time. An attempt to put a message to a queue that already contains this many
messages fails with reason code MQException.MQRC_Q_FULL.
getMaximumMessageLength
public int getMaximumMessageLength()
Throws MQException.
This is the maximum length of the application data that can exist in each
message on this queue. An attempt to put a message larger than this value
fails with reason code MQException.MQRC_MSG_TOO_BIG_FOR_Q.
getOpenInputCount
public int getOpenInputCount()
Throws MQException.
The number of handles that are currently valid for removing messages from the
queue. This is the total number of such handles known to the local queue
manager, not just those created by the MQSeries classes for Java (using
accessQueue).
getOpenOutputCount
public int getOpenOutputCount()
Throws MQException.
The number of handles that are currently valid for adding messages to the
queue. This is the total number of such handles known to the local queue
manager, not just those created by the MQSeries classes for Java (using
accessQueue).
getShareability
public int getShareability()
Throws MQException.
Indicates whether the queue can be opened for input multiple times.
Returns
One of the following:
MQC.MQQA_SHAREABLE
MQC.MQQA_NOT_SHAREABLE
getInhibitPut
public int getInhibitPut()
Throws MQException.
Indicates whether or not put operations are allowed for this queue.
Returns
One of the following:
MQC.MQQA_PUT_INHIBITED
MQC.MQQA_PUT_ALLOWED
setInhibitPut
public void setInhibitPut(int inhibit)
Throws MQException.
Controls whether or not put operations are allowed for this queue. The
permissible values are:
MQC.MQQA_PUT_INHIBITED
MQC.MQQA_PUT_ALLOWED
getInhibitGet
public int getInhibitGet()
Throws MQException.
Indicates whether or not get operations are allowed for this queue.
Returns
The possible values are:
MQC.MQQA_GET_INHIBITED
MQC.MQQA_GET_ALLOWED
setInhibitGet
public void setInhibitGet(int inhibit)
Throws MQException.
Controls whether or not get operations are allowed for this queue. The
permissible values are:
MQC.MQQA_GET_INHIBITED
MQC.MQQA_GET_ALLOWED
getTriggerControl
public int getTriggerControl()
Throws MQException.
Indicates whether or not trigger messages are written to an initiation queue, in
order to cause an application to be started to service the queue.
Returns
The possible values are:
MQC.MQTC_OFF
MQC.MQTC_ON
setTriggerControl
public void setTriggerControl(int trigger)
Throws MQException.
Controls whether or not trigger messages are written to an initiation queue, in
order to cause an application to be started to service the queue. The
permissible values are:
MQC.MQTC_OFF
MQC.MQTC_ON
getTriggerData
public String getTriggerData()
Throws MQException.
The free-format data that the queue manager inserts into the trigger message
when a message arriving on this queue causes a trigger message to be written
to the initiation queue.
setTriggerData
public void setTriggerData(String data)
Throws MQException.
Sets the free-format data that the queue manager inserts into the trigger
message when a message arriving on this queue causes a trigger message to
be written to the initiation queue. The maximum permissible length of the
string is given by MQC.MQ_TRIGGER_DATA_LENGTH.
getTriggerDepth
public int getTriggerDepth()
Throws MQException.
The number of messages that have to be on the queue before a trigger
message is written when trigger type is set to MQC.MQTT_DEPTH.
setTriggerDepth
public void setTriggerDepth(int depth)
Throws MQException.
Sets the number of messages that have to be on the queue before a trigger
message is written when trigger type is set to MQC.MQTT_DEPTH.
getTriggerMessagePriority
public int getTriggerMessagePriority()
Throws MQException.
This is the message priority below which messages do not contribute to the
generation of trigger messages (that is, the queue manager ignores these
messages when deciding whether a trigger should be generated). A value of
zero causes all messages to contribute to the generation of trigger messages.
setTriggerMessagePriority
public void setTriggerMessagePriority(int priority)
Throws MQException.
Sets the message priority below which messages do not contribute to the
generation of trigger messages (that is, the queue manager ignores these
messages when deciding whether a trigger should be generated). A value of
zero causes all messages to contribute to the generation of trigger messages.
getTriggerType
public int getTriggerType()
Throws MQException.
The conditions under which trigger messages are written as a result of
messages arriving on this queue.
Returns
The possible values are:
MQC.MQTT_NONE
MQC.MQTT_FIRST
MQC.MQTT_EVERY
MQC.MQTT_DEPTH
setTriggerType
public void setTriggerType(int type)
Throws MQException.
Sets the conditions under which trigger messages are written as a result of
messages arriving on this queue. The possible values are:
MQC.MQTT_NONE
MQC.MQTT_FIRST
MQC.MQTT_EVERY
MQC.MQTT_DEPTH
close
public synchronized void close()
Throws MQException.
Override of "MQManagedObject.close" on page 67
MQQueueManager
java.lang.Object
│
└─ com.ibm.mq.MQManagedObject
│
└─ com.ibm.mq.MQQueueManager
Variables
isConnected
public boolean isConnected
True if the connection to the queue manager is still open.
Constructors
MQQueueManager
public MQQueueManager(String queueManagerName)
Throws MQException.
Create a connection to the named queue manager.
Note: When using the MQSeries classes for Java, the hostname, channel
name and port to use during the connection request are specified in the
MQEnvironment class. This must be done before calling this constructor.
The following example shows a connection to a queue manager "MYQM",
running on a machine with hostname fred.mq.com.
MQEnvironment.hostname = "fred.mq.com"; // host to connect to
MQEnvironment.port = 1414; // port to connect to.
// If I don't set this,
// it defaults to 1414
// (the default MQSeries port)
MQEnvironment.channel = "channel.name"; // the CASE-SENSITIVE
// name of the
// SVR CONN channel on
// the queue manager
MQQueueManager qMgr = new MQQueueManager("MYQM");
If the queue manager name is left blank (null or ""), a connection is made to
the default queue manager.
See also “MQEnvironment” on page 55.
MQQueueManager
public MQQueueManager(String queueManagerName, int options)
Throws MQException.
This version of the constructor is intended for use only in bindings mode and it
uses the extended connection API (MQCONNX) to connect to the queue
manager. The options parameter allows you to choose fast or normal bindings.
Possible values are:
MQC.MQCNO_FASTPATH_BINDING for fast bindings *
MQC.MQCNO_STANDARD_BINDING for normal bindings
MQQueueManager
public MQQueueManager(String queueManagerName,
java.util.Hashtable properties)
The properties parameter takes a series of key/value pairs that describe the
MQSeries environment for this particular queue manager. These properties,
where specified, override the values set by the MQEnvironment class, and
allow the individual properties to be set on a queue manager by queue
manager basis. See "MQEnvironment.properties" on page 56.
Methods
getCharacterSet
public int getCharacterSet()
Throws MQException.
Returns the CCSID (Coded Character Set Identifier) of the queue manager's
codeset. This defines the character set used by the queue manager for all
character string fields in the application programming interface.
Throws MQException if you call this method after disconnecting from the
queue manager.
getMaximumMessageLength
public int getMaximumMessageLength()
Throws MQException.
Returns the maximum length of a message (in bytes) that can be handled by
the queue manager. No queue can be defined with a maximum message
length greater than this.
Throws MQException if you call this method after disconnecting from the
queue manager.
getCommandLevel
public int getCommandLevel()
Throws MQException.
Indicates the level of system control commands supported by the queue
manager. The set of system control commands that correspond to a particular
command level varies according to the architecture of the platform on which
the queue manager is running. See the MQSeries documentation for your
platform for further details.
Throws MQException if you call this method after disconnecting from the
queue manager.
Returns
One of the MQC.MQCMDL_LEVEL_xxx constants
getCommandInputQueueName
public String getCommandInputQueueName()
Throws MQException.
Returns the name of the command input queue defined on the queue
manager. This is a queue to which applications can send commands, if
authorized to do so.
Throws MQException if you call this method after disconnecting from the
queue manager.
getMaximumPriority
public int getMaximumPriority()
Throws MQException.
Returns the maximum message priority supported by the queue manager.
Priorities range from zero (lowest) to this value.
Throws MQException if you call this method after disconnecting from the
queue manager.
getSyncpointAvailability
public int getSyncpointAvailability()
Throws MQException.
Indicates whether the queue manager supports units of work and syncpointing
with the MQQueue.get and MQQueue.put methods.
Returns
MQC.MQSP_AVAILABLE if syncpointing is available
MQC.MQSP_NOT_AVAILABLE if syncpointing is not available
Throws MQException if you call this method after disconnecting from the
queue manager.
getDistributionListCapable
public boolean getDistributionListCapable()
Indicates whether the queue manager supports distribution lists
disconnect
public synchronized void disconnect()
Throws MQException.
Terminates the connection to the queue manager. All open queues and
processes accessed by this queue manager are closed, and hence become
unusable. When you have disconnected from a queue manager the only way
to reconnect is to create a new MQQueueManager object.
commit
public synchronized void commit()
Throws MQException.
Calling this method indicates to the queue manager that the application has
reached a syncpoint, and that all of the message gets and puts that have
occurred since the last syncpoint are to be made permanent. Messages put as
part of a unit of work (with the MQC.MQPMO_SYNCPOINT flag set in the
options field of MQPutMessageOptions) are made available to other
applications. Messages retrieved as part of a unit of work (with the
MQC.MQGMO_SYNCPOINT flag set in the options field of
MQGetMessageOptions) are deleted.
See also the description of "backout" that follows.
backout
public synchronized void backout()
Throws MQException.
Calling this method indicates to the queue manager that all the message gets
and puts that have occurred since the last syncpoint are to be backed out.
Messages put as part of a unit of work (with the MQC.MQPMO_SYNCPOINT
flag set in the options field of MQPutMessageOptions) are deleted; messages
retrieved as part of a unit of work (with the MQC.MQGMO_SYNCPOINT flag
set in the options field of MQGetMessageOptions) are reinstated on the queue.
See also the decription of "commit" above.
accessQueue
public synchronized MQQueue accessQueue
(
String queueName, int openOptions,
String queueManagerName,
String dynamicQueueName,
String alternateUserId
)
Throws MQException.
Establishes access to an MQSeries queue on this queue manager to get or
browse messages, put messages, inquire about the attributes of the queue or
set the attributes of the queue.
If the queue named is a model queue, then a dynamic local queue is created.
The name of the created queue can be determined by inspecting the name
attribute of the returned MQQueue object.
Parameters
queueName
Name of queue to open
openOptions
Options that control the opening of the queue. Valid options are:
MQC.MQOO_BROWSE
Open to browse message.
MQC.MQOO_INPUT_AS_Q_DEF
Open to get messages using queue-defined default.
MQC.MQOO_INPUT_SHARED
Open to get messages with shared access.
MQC.MQOO_INPUT_EXCLUSIVE
Open to get messages with exclusive access.
MQC.MQOO_OUTPUT
Open to put messages.
MQC.MQOO_INQUIRE
Open for inquiry - required if you wish to query properties.
MQC.MQOO_SET
Open to set attributes.
MQC.MQOO_SAVE_ALL_CONTEXT
Save context when message retrieved*.
MQC.MQOO_SET_IDENTITY_CONTEXT
Allows identity context to be set.
MQC.MQOO_SET_ALL_CONTEXT
Allows all context to be set.
MQC.MQOO_ALTERNATE_USER_AUTHORITY
Validate with the specified user identifier.
MQC.MQOO_FAIL_IF_QUIESCING
Fail if the queue manager is quiescing.
MQC.MQOO_BIND_AS_QDEF
Use default binding for queue.
MQC.MQOO_BIND_ON_OPEN
Bind handle to destination when queue is opened.
MQC.MQOO_BIND_NOT_FIXED
Do not bind to a specific destination.
If more than one option is required the values can be added together or
combined using the bitwise OR operator. See the MQSeries Application
Programming Reference for a fuller description of these options.
queueManagerName
Name of the queue manager on which the queue is defined. A name
which is entirely blank, or which is null, denotes the queue manager to
which this MQQueueManager object is connected.
dynamicQueueName
This parameter is ignored unless queueName specifies the name of a
model queue. If it does, this parameter specifies the name of the dynamic
queue to be created. A blank or null name is not valid if queueName
specifies the name of a model queue. If the last non-blank character in
the name is an asterisk (*), the queue manager replaces the asterisk with
a string of characters that guarantees that the name generated for the
queue is unique on this queue manager.
alternateUserId
If MQOO_ALTERNATE_USER_AUTHORITY is specified in the
openOptions parameter this parameter specifies the alternate user
alternateUserId
If MQOO_ALTERNATE_USER_AUTHORITY is specified in the
openOptions parameter this parameter specifies the alternate user
identifier that is to be used to check the authorization for the open. If
MQOO_ALTERNATE_USER_AUTHORITY is not specified this parameter
can be left blank (or null).
Returns
A newly created MQDistributionList which is open and ready for put
operations.
Throws MQException if the open fails.
See also "accessQueue" on page 104.
accessDistributionList
This is a simplified version of the AccessDistributionList method previously
described.
public synchronized MQDistributionList accessDistributionList
(
MQDistributionListItem[] litems,
int openOptions,
)
Parameters
litems
The items to be included in the distribution list.
openOptions
Options that control the opening of the distribution list.
See "accessDistributionList" on page 107 for details of the parameters.
alternateUserId is set to "".
begin* (bindings connection only)
public synchronized void begin()
Throws MQException.
This method is supported only by the MQSeries classes for Java in bindings
mode and it signals the queue manager that a new unit of work is starting.
isConnected
public boolean void isConnected()
Returns the value of the isConnected variable.
MQC
public interface MQC
extends Object
The MQC interface defines all the constants used by the MQSeries classes for
Java. To refer to one of these constants from within your programs, prefix the
constant name with "MQC.". For example, you can set the close options for a
queue as follows:
MQQueue queue;
...
queue.closeOptions = MQC.MQCO_DELETE; // delete the
// queue when
// it is closed
...
A full description of these constants can be found inChapter 6, “MQSeries
constants” in the MQSeries Application Programming Reference book.
MQReceiveExit
public interface MQReceiveExit
extends Object
The receive exit interface allows you to examine and possibly alter the data
received from the queue manager by the MQSeries classes for Java.
Note: This class does not apply when connecting directly to MQSeries in bindings
mode.
To provide your own receive exit, define a class that implements this interface.
Create a new instance of your class and assign the MQEnvironment.receiveExit
variable to it before constructing your MQQueueManager object. For example:
// in MyReceiveExit.java
class MyReceiveExit implements MQReceiveExit {
// you must provide an implementation
// of the receiveExit method
public byte[] receiveExit(
MQChannelExit channelExitParms,
MQChannelDefinition channelDefinition,
byte[] agentBuffer)
{
// your exit code goes here...
}
}
// in your main program...
MQEnvironment.receiveExit = new MyReceiveExit();
... // other initialization
MQQueueManager qMgr = new MQQueueManager("");
Methods
receiveExit
public abstract byte[] receiveExit(MQChannelExit channelExitParms,
MQChannelDefinition channelDefinition,
byte agentBuffer[])
The receive exit method that your class must provide. This method will be
invoked whenever the MQSeries classes for Java receive some data from the
queue manager.
Parameters
channelExitParms
Contains information regarding the context in which the exit is being
invoked. The exitResponse member variable is an output parameter that
you use to tell the MQSeries classes for Java what action to take next.
See “MQChannelExit” on page 48 for further details.
channelDefinition
Contains details of the channel through which all communications with the
queue manager take place.
agentBuffer
If the channelExitParms.exitReason is MQChannelExit.MQXR_XMIT,
agentBuffer contains the data received from the queue manager; otherwise
agentBuffer is null.
Returns
If the exit response code (in channelExitParms) is set so that the MQSeries
classes for Java can now process the data (MQXCC_OK), your receive exit
method must return the data to be processed. The simplest receive exit,
therefore, consists of the single line "return agentBuffer;".
See also:
“MQC” on page 109
“MQChannelDefinition” on page 46
MQSecurityExit
public interface MQSecurityExit
extends Object
The security exit interface allows you to customize the security flows that occur
when an attempt is made to connect to a queue manager.
Note: This class does not apply when connecting directly to MQSeries in bindings
mode.
To provide your own security exit, define a class that implements this interface.
Create a new instance of your class and assign the MQEnvironment.securityExit
variable to it before constructing your MQQueueManager object. For example:
// in MySecurityExit.java
class MySecurityExit implements MQSecurityExit {
// you must provide an implementation
// of the securityExit method
public byte[] securityExit(
MQChannelExit channelExitParms,
MQChannelDefinition channelDefinition,
byte[] agentBuffer)
{
// your exit code goes here...
}
}
// in your main program...
MQEnvironment.securityExit = new MySecurityExit();
... // other initialization
MQQueueManager qMgr = new MQQueueManager("");
Methods
securityExit
public abstract byte[] securityExit(MQChannelExit channelExitParms,
MQChannelDefinition channelDefinition,
byte agentBuffer[])
Returns
If the exit response code (in channelExitParms) is set so that a message is to
be transmitted to the queue manager, your security exit method must return
the data to be transmitted.
See also:
“MQC” on page 109
“MQChannelDefinition” on page 46
MQSendExit
public interface MQSendExit
extends Object
The send exit interface allows you to examine and possibly alter the data sent to
the queue manager by the MQSeries classes for Java.
Note: This class does not apply when connecting directly to MQSeries in bindings
mode.
To provide your own send exit, define a class that implements this interface.
Create a new instance of your class and assign the MQEnvironment.sendExit
variable to it before constructing your MQQueueManager object. For example:
// in MySendExit.java
class MySendExit implements MQSendExit {
// you must provide an implementation of the sendExit method
public byte[] sendExit(
MQChannelExit channelExitParms,
MQChannelDefinition channelDefinition,
byte[] agentBuffer)
{
// your exit code goes here...
}
}
// in your main program...
MQEnvironment.sendExit = new MySendExit();
... // other initialization
MQQueueManager qMgr = new MQQueueManager("");
Methods
sendExit
public abstract byte[] sendExit(MQChannelExit channelExitParms,
MQChannelDefinition channelDefinition,
byte agentBuffer[])
The send exit method that your class must provide. This method is invoked
whenever the MQSeries classes for Java wish to transmit some data to the
queue manager.
Parameters
channelExitParms
Contains information regarding the context in which the exit is being
invoked. The exitResponse member variable is an output parameter that
you use to tell the MQSeries classes for Java what action to take next.
See “MQChannelExit” on page 48 for further details.
channelDefinition
Contains details of the channel through which all communications with the
queue manager take place.
agentBuffer
If the channelExitParms.exitReason is MQChannelExit.MQXR_XMIT,
agentBuffer contains the data to be transmitted to the queue manager;
otherwise agentBuffer is null.
Returns
If the exit response code (in channelExitParms) is set so that a message is to
be transmitted to the queue manager (MQXCC_OK), your send exit method
must return the data to be transmitted. The simplest send exit, therefore,
consists of the single line "return agentBuffer;".
See also:
“MQC” on page 109
“MQChannelDefinition” on page 46
Appendix A. Notices
This information was developed for products and services offered in the United
States. IBM may not offer the products, services, or features discussed in this
information in other countries. Consult your local IBM representative for information
on the products and services currently available in your area. Any reference to an
IBM product, program, or service is not intended to state or imply that only that IBM
product, program, or service may be used. Any functionally equivalent product,
program, or service that does not infringe any IBM intellectual property right may be
used instead. However, it is the user’s responsibility to evaluate and verify the
operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter
described in this information. The furnishing of this information does not give you
any license to these patents. You can send license inquiries, in writing, to:
IBM Director of Licensing
IBM Corporation
North Castle Drive
Armonk, NY 10504-1785
U.S.A.
For license inquiries regarding double-byte (DBCS) information, contact the IBM
Intellectual Property Department in your country or send inquiries, in writing, to:
IBM World Trade Asia Corporation
Licensing
2-31 Roppongi 3-chome, Minato-ku
Tokyo 106, Japan
The following paragraph does not apply to the United Kingdom or any other
country where such provisions are inconsistent with local law:
INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS
PUBLICATION “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A
PARTICULAR PURPOSE. Some states do not allow disclaimer of express or
implied warranties in certain transactions, therefore this statement may not apply to
you.
Licensees of this program who wish to have information about it for the purpose of
enabling: (i) the exchange of information between independently created programs
and other programs (including this one) and (ii) the mutual use of the information
which has been exchanged, should contact:
IBM United Kingdom Laboratories,
Mail Point 151,
Hursley Park,
Winchester,
Hampshire,
England
SO21 2JN.
The licensed program described in this information and all licensed material
available for it are provided by IBM under terms of the IBM Customer Agreement,
IBM International Programming License Agreement, or any equivalent agreement
between us.
Trademarks
The following terms are trademarks of International Business Machines Corporation
in the United States, or other countries, or both:
Java and all Java-based trademarks and logos are trademarks or registered
trademarks of Sun Microsystems, Inc. in the United States and/or other countries.
Microsoft, Windows, Windows NT, and the Windows logo are trademarks of
Microsoft Corporation in the United States and/or other countries.
UNIX is a registered trademark in the United States and/or other countries licensed
exclusively through X/Open Company Limited.
If you do not find the term you are looking for, see the
index or the IBM Dictionary of Computing, New York: Internet. The Internet is a cooperative public network
McGraw-Hill, 1994. of shared information. Physically, the Internet uses a
subset of the total resources of all the currently existing
applet. A Java program which is designed to run only public telecommunication networks. Technically, what
on a web page. distinguishes the Internet as a cooperative public
network is its use of a set of protocols called TCP/IP
(Transport Control Protocol/Internet Protocol).
Application Programming Interface (API). An
Application Programming Interface consists of the
functions and variables that programmers are allowed to Java Developers Kit (JDK). A package of software
use in their applications. distributed by Sun Microsystems for Java developers. It
includes the Java interpreter, Java classes and Java
development tools: compiler, debugger, disassembler,
channel. See MQI channel. appletviewer, stub file generator, and documentation
generator.
IIOP. Internet Inter-ORB Protocol. A standard for MQSeries. MQSeries is a family of IBM licensed
TCP/IP communications between ORBs from different programs that provide message queuing services.
vendors.
Object Request Broker (ORB). An application requests for information in the particular two-program
framework that provides interoperability between information flow model of client/server. (3) The
objects, built in different languages, running on different computer on which a server program runs.
machines, in heterogeneous distributed environments.
server. (1) An MQSeries a server is a queue World Wide Web (Web). The World Wide Web is an
manager that provides message queuing services to Internet service, based on a common set of protocols,
client applications running on a remote workstation. (2) which allows a particularly configured server computer
More generally, a server is a program that responds to to distribute documents across the Internet in a
standard way.
Index
code examples 22
A com.ibm.mq.iiop.jar 6
about this book vii com.ibm.mq.jar 6
accessing queues and processes 29 com.ibm.mqbind.jar 6
advantages of Java interface 17 compiling MQSeries classes for Java programs 35
applet example 22 configuring
applet viewer, using 9 queue manager for clients 9
applets versus applications 21 Web server 7
applets, running 28 connecting to a queue manager 29
application example 26 connection type, defining 22
applications versus applets 21 connections vii
binding 5
client 4
B client, programming 21
behavior in different environments 39
options 4
bibliography viii
programming 21
bindings
core classes 39
connection 5
exceptions 40
connection, programming 22
extensions for V5 41
verifying 11
customizing the sample applet 11
BookManager xiii
C D
defining connection type 22
changed function vii
differences between applets and applications 21
changes in this version vii
differences due to environment 39
class library 19
directories, installation 6
classes, MQSeries classes for Java 45
disconnecting from a queue manager 29
MQC 109
MQChannelDefinition 46
MQChannelExit 48 E
MQDistributionList 51 environment differences 39
MQDistributionListItem 53 error messages 14
MQEnvironment 55 errors, handling 32
MQException 59 example code 22
MQGetMessageOptions 61 exceptions to core classes 40
MQManagedObject 65 extensions to core classes for V5 41
MQMessage 68
MQMessageTracker 86
MQProcess 88 F
MQPutMessageOptions 90 function, changes vii
MQQueue 93
MQQueueManager 101
MQReceiveExit 110 G
MQSecurityExit 112 getting started 3
MQSendExit 114 glossary 125
CLASSPATH, updating 6
clients
configuring queue manager 9
H
handling
connection 4
errors 32
programming 21
messages 30
verifying 11
O
J Operations on queue managers 28
jar files 6 options
Java classes 19, 45 connection vii, 4
Java Developers Kit 18 transport vii
Java interface, advantages 17
JDK 18
P
packaging vii
L PDF (Portable Document Format) xiii
library, Java classes 19 platform differences 39
Portable Document Format (PDF) xiii
PostScript format xiv
M prerequesites 5
messages problems, solving 13
error 14 processes, accessing 29
handling 30 progams, running 35
MQC 109 programmers, introduction 17
MQChannelDefinition 46 programming
MQChannelExit 48 bindings connection 22
MQDistributionList 51 client connections 21
MQDistributionListItem 53 compiling 35
MQEnvironment 22, 28, 55 connections 21
MQException 59 multithreaded 33
MQGetMessageOptions 61 tracing 35
MQIVP writing 21
listing 12 programming interface 18
sample application 11 publications
tracing 13 MQSeries viii
mqjavac
tracing 13
using to verify 9 Q
MQManagedObject 65 queue manager, configuring for clients 9
MQMessage 68 queues, accessing 29
MQMessageTracker 86
MQProcess 88
MQPutMessageOptions 90 R
MQQueue 93 reading strings 31
MQQueueManager 29, 101 running
MQReceiveExit 110 applets 28
MQSecurityExit 112 in a Web browser 4
MQSendExit 114 MQSeries classes for Java programs 35
MQSeries classes for Java classes 45 stand-alone 4
with applet viewer 4
running (continued)
your own programs 12 W
Web browser
using 4
S with sample applet 10
sample applet Web server, configuring 7
customizing 11 Windows Help xiv
tracing 13 writing
using to verify 9 programs 21
with applet viewer 10 user exits 33
with Web browser 10
sample application
tracing 13
using to verify 11
set and inquire 32
softcopy books xiii
software requirements 5
solving problems 13
stand-alone, running 4
strings 31
strings, reading and writing 31
T
TCP/IP
client verifying 11
connection, programming 21
using 4
testing MQSeries classes for Java progams 35
tracing
programs 35
sample applet 13
the sample application 13
transport options vii
U
updating your CLASSPATH 6
user exits, writing 33
uses for MQSeries 3
using
applet viewer 9
the MQSeries classes for Java 9
V
v5 extensions 41
verbs, MQSeries supported 18
verifying
client mode installation 9
TCP/IP clients 11
with the sample applet 9
with the sample application 11
Visibroker viii
using 4, 12
Index 129
Sending your comments to IBM
MQSeries
Using Java
SC34-5456-00
If you especially like or dislike anything about this book, please use one of the methods listed below to
send your comments to IBM.
Feel free to comment on what you regard as specific errors or omissions, and on the accuracy,
organization, subject matter, or completeness of this book. Please limit your comments to the information
in this book and the way in which the information is presented.
To request additional publications, or to ask questions or make comments about the functions of IBM
products or systems, you should talk to your IBM representative or to your IBM authorized remarketer.
When you send comments to IBM, you grant IBM a nonexclusive right to use or distribute your comments
in any way it believes appropriate, without incurring any obligation to you.
You can send your comments to IBM in any of the following ways:
By mail, use the Readers’ Comment Form
By fax:
– From outside the U.K., after your international access code use 44 1962 870229
– From within the U.K., use 01962 870229
Electronically, use the appropriate network ID:
– IBM Mail Exchange: GBIBM2Q9 at IBMMAIL
– IBMLink: HURSLEY(IDRCF)
– Internet: [email protected]
Whichever you use, ensure that you include:
The publication number and title
The page number or topic to which your comment applies
Your name and address/telephone number/fax number/network ID.
Readers’ Comments
MQSeries
Using Java
SC34-5456-00
Use this form to tell us what you think about this manual. If you have found errors in it, or if you want
to express your opinion about it (such as organization, subject matter, appearance) or make
suggestions for improvement, this is the form to use.
To request additional publications, or to ask questions or make comments about the functions of IBM
products or systems, you should talk to your IBM representative or to your IBM authorized remarketer.
This form is provided for comments about the information in this manual and the way it is presented.
When you send comments to IBM, you grant IBM a nonexclusive right to use or distribute your
comments in any way it believes appropriate without incurring any obligation to you.
Be sure to print your name and address below if you would like a reply.
Name Address
Company or Organization
Telephone Email
MQSeries
Par avion
IBRS/CCRI NUMBER: PHQ - D/1348/SO
NO STAMP REQUIRED
REPONSE PAYEE
GRANDE-BRETAGNE
IBM United Kingdom Laboratories
Information Development Department (MP095)
Hursley Park,
WINCHESTER, Hants
SO21 2ZZ United Kingdom
From: Name
Company or Organization
Cut along this line
Address
EMAIL
Telephone
SC34-5456-ðð
Spine information:
IBM MQSeries Using Java