174 lines
11 KiB
HTML
174 lines
11 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE html
|
||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html lang="en-us" xml:lang="en-us">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<meta name="security" content="public" />
|
||
|
<meta name="Robots" content="index,follow" />
|
||
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
||
|
<meta name="DC.Type" content="reference" />
|
||
|
<meta name="DC.Title" content="Message classes" />
|
||
|
<meta name="abstract" content="" />
|
||
|
<meta name="description" content="" />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="msg" />
|
||
|
<meta name="DC.Language" content="en-us" />
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
||
|
<title>Message classes</title>
|
||
|
</head>
|
||
|
<body id="msg"><a name="msg"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Message classes</h1>
|
||
|
<div><p></p>
|
||
|
<div class="section" id="msg__as400message"><a name="msg__as400message"><!-- --></a><h4 class="sectiontitle">AS400Message</h4><p><a href="javadoc/com/ibm/as400/access/AS400Message.html#NAVBAR_TOP">AS400Message</a> object
|
||
|
allows the Java™ program to retrieve an i5/OS™ message that is generated from a
|
||
|
previous operation (for example, from a command call). From a message object,
|
||
|
the Java program
|
||
|
can retrieve the following:</p>
|
||
|
<ul><li>The iSeries™ <a href="javadoc/com/ibm/as400/access/AS400Message.html#GETLIBRARYNAME()"> library</a> and message <a href="javadoc/com/ibm/as400/access/AS400Message.html#GETFILENAME()"> file</a> that contain the message</li>
|
||
|
<li>The message <a href="javadoc/com/ibm/as400/access/AS400Message.html#GETID()"> ID</a></li>
|
||
|
<li>The message <a href="javadoc/com/ibm/as400/access/AS400Message.html#GETTYPE()"> type</a></li>
|
||
|
<li>The message <a href="javadoc/com/ibm/as400/access/AS400Message.html#GETSEVERITY()"> severity</a></li>
|
||
|
<li>The message <a href="javadoc/com/ibm/as400/access/AS400Message.html#GETTEXT()"> text</a></li>
|
||
|
<li>The message <a href="javadoc/com/ibm/as400/access/AS400Message.html#GETHELP()">help text</a></li>
|
||
|
</ul>
|
||
|
<div class="p" id="msg__msgex1"><a name="msg__msgex1"><!-- --></a>The following example shows how to use the AS400Message
|
||
|
object:<div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code
|
||
|
example disclaimer</a> for important legal information.</div>
|
||
|
</div>
|
||
|
<pre> // Create a command call object.
|
||
|
CommandCall cmd = new CommandCall(sys, "myCommand");
|
||
|
|
||
|
// Run the command
|
||
|
cmd.run();
|
||
|
|
||
|
// Get the list of messages that are
|
||
|
// the result of the command that I
|
||
|
// just ran
|
||
|
AS400Message[] messageList = cmd.getMessageList();
|
||
|
|
||
|
// Iterate through the list
|
||
|
// displaying the messages
|
||
|
for (int i = 0; i < messageList.length; i++)
|
||
|
{
|
||
|
System.out.println(messageList[i].getText());
|
||
|
}</pre>
|
||
|
</div>
|
||
|
<div class="section" id="msg__msgexamples"><a name="msg__msgexamples"><!-- --></a><h4 class="sectiontitle">Examples: Using message lists</h4><p>The
|
||
|
following examples show how you can use message lists with CommandCall and
|
||
|
ProgramCall.</p>
|
||
|
<ul><li><strong></strong> <a href="commandcallexample.htm#commandcallexample">Example: Using CommandCall</a></li>
|
||
|
<li><strong></strong> <a href="pcsystemstatexample.htm#pcsystemstatexample">Example: Using ProgramCall</a></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<div class="section" id="msg__qmsg"><a name="msg__qmsg"><!-- --></a><h4 class="sectiontitle">QueuedMessage</h4><p>The <a href="javadoc/com/ibm/as400/access/QueuedMessage.html#NAVBAR_TOP">QueuedMessage</a> class extends the AS400Message class.</p>
|
||
|
<div class="note"><span class="notetitle">Note:</span> Toolbox
|
||
|
for Java also
|
||
|
provides <a href="resources.htm#resources">resource classes</a> that
|
||
|
present a generic framework and consistent programming interface for working
|
||
|
with various iSeries objects
|
||
|
and lists. After reading about the classes in the <a href="javadoc/com/ibm/as400/access/package-summary.html#NAVBAR_TOP">access package</a> and the <a href="javadoc/com/ibm/as400/resource/package-summary.html#NAVBAR_TOP">resource package</a>, you can choose the object that works
|
||
|
best for your application. The resource class for working with queued messages
|
||
|
is <a href="javadoc/com/ibm/as400/resource/RQueuedMessage.html#NAVBAR_TOP">RQueuedMessage</a>.</div>
|
||
|
<p>The QueuedMessage class accesses
|
||
|
information about a message on an iSeries message queue. With this class,
|
||
|
a Java program
|
||
|
can retrieve:</p>
|
||
|
<ul><li>Information about where a message originated, such as <a href="javadoc/com/ibm/as400/access/QueuedMessage.html#GETFROMPROGRAM()">program</a>,
|
||
|
<a href="javadoc/com/ibm/as400/access/QueuedMessage.html#GETFROMJOBNAME()">job name</a>, <a href="javadoc/com/ibm/as400/access/QueuedMessage.html#GETFROMJOBNUMBER()">job number</a>, and <a href="javadoc/com/ibm/as400/access/QueuedMessage.html#GETUSER()">user</a></li>
|
||
|
<li>The message <a href="javadoc/com/ibm/as400/access/QueuedMessage.html#GETQUEUE()">queue</a></li>
|
||
|
<li>The message <a href="javadoc/com/ibm/as400/access/QueuedMessage.html#GETKEY()">key</a></li>
|
||
|
<li>The message <a href="javadoc/com/ibm/as400/access/QueuedMessage.html#GETREPLYSTATUS()">reply status</a></li>
|
||
|
</ul>
|
||
|
<div class="p" id="msg__msgex2"><a name="msg__msgex2"><!-- --></a>The following example prints all messages in the message
|
||
|
queue of the current (signed-on) user: <div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code
|
||
|
example disclaimer</a> for important legal information.</div>
|
||
|
</div>
|
||
|
<pre> // The message queue is on this iSeries.
|
||
|
AS400 sys = new AS400(mySystem.myCompany.com);
|
||
|
|
||
|
// Create the message queue object.
|
||
|
// This object will represent the
|
||
|
// queue for the current user.
|
||
|
MessageQueue queue = new MessageQueue(sys, MessageQueue.CURRENT);
|
||
|
|
||
|
// Get the list of messages currently
|
||
|
// in this user's queue.
|
||
|
Enumeration e = queue.getMessages();
|
||
|
|
||
|
// Print each message in the queue.
|
||
|
while (e.hasMoreElements())
|
||
|
{
|
||
|
QueuedMessage msg = e.getNextElement();
|
||
|
System.out.println(msg.getText());
|
||
|
}</pre>
|
||
|
</div>
|
||
|
<div class="section" id="msg__msgf"><a name="msg__msgf"><!-- --></a><h4 class="sectiontitle">MessageFile</h4><p>The <a href="javadoc/com/ibm/as400/access/MessageFile.html#NAVBAR_TOP"> MessageFile</a> class allows you to receive a message from
|
||
|
an iSeries message
|
||
|
file. The MessageFile class returns an AS400Message object that contains the
|
||
|
message. Using the MessageFile class, you can do the following:</p>
|
||
|
<ul><li>Return a <a href="javadoc/com/ibm/as400/access/MessageFile.html#GETMESSAGE(JAVA.LANG.STRING)"> message object</a> that contains the message</li>
|
||
|
<li>Return a message object that contains <a href="javadoc/com/ibm/as400/access/MessageFile.html#GETMESSAGE(JAVA.LANG.STRING, JAVA.LANG.STRING)"> substitution text</a> in the message</li>
|
||
|
</ul>
|
||
|
<div class="p" id="msg__msgex4"><a name="msg__msgex4"><!-- --></a>The following example shows how to retrieve and print
|
||
|
a message: <div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code
|
||
|
example disclaimer</a> for important legal information.</div>
|
||
|
</div>
|
||
|
<pre> AS400 system = new AS400("mysystem.mycompany.com");
|
||
|
MessageFile messageFile = new MessageFile(system);
|
||
|
messageFile.setPath("/QSYS.LIB/QCPFMSG.MSGF");
|
||
|
AS400Message message = messageFile.getMessage("CPD0170");
|
||
|
System.out.println(message.getText());</pre>
|
||
|
</div>
|
||
|
<div class="section" id="msg__msgq"><a name="msg__msgq"><!-- --></a><h4 class="sectiontitle">MessageQueue</h4><p>The <a href="javadoc/com/ibm/as400/access/MessageQueue.html#NAVBAR_TOP"> MessageQueue</a> class allows a Java program to interact with an iSeries message
|
||
|
queue.</p>
|
||
|
<div class="note"><span class="notetitle">Note:</span> Toolbox for Java also provides <a href="resources.htm#resources">resource
|
||
|
classes</a> that present a generic framework and consistent programming
|
||
|
interface for working with various iSeries objects and lists. After reading
|
||
|
about the classes in the <a href="javadoc/com/ibm/as400/access/package-summary.html#NAVBAR_TOP">access package</a> and the <a href="javadoc/com/ibm/as400/resource/package-summary.html#NAVBAR_TOP">resource package</a>, you can choose the object that works
|
||
|
best for your application. The resource class for working with message queues
|
||
|
is <a href="javadoc/com/ibm/as400/resource/RMessageQueue.html#NAVBAR_TOP">RMessageQueue</a>.</div>
|
||
|
<p>The MessageQueue class acts as
|
||
|
a container for the QueuedMessage class. The <a href="javadoc/com/ibm/as400/access/MessageQueue.html#GETMESSAGES()">getMessages()</a> method, in particular, returns a list of
|
||
|
QueuedMessage objects. The MessageQueue class can do the following:</p>
|
||
|
<ul><li><a href="javadoc/com/ibm/as400/access/MessageQueue.html#SETPATH(JAVA.LANG.STRING)">Set</a> message queue attributes</li>
|
||
|
<li><a href="javadoc/com/ibm/as400/access/MessageQueue.html#GETLENGTH()">Get</a> information about a message queue</li>
|
||
|
<li><a href="javadoc/com/ibm/as400/access/MessageQueue.html#RECEIVE(BYTE[])">Receive</a> messages from a message queue</li>
|
||
|
<li><a href="javadoc/com/ibm/as400/access/MessageQueue.html#SENDINFORMATIONAL(JAVA.LANG.STRING, JAVA.LANG.STRING)">Send</a> messages to a message queue</li>
|
||
|
<li><a href="javadoc/com/ibm/as400/access/MessageQueue.html#REPLY">Reply</a> to messages</li>
|
||
|
</ul>
|
||
|
<div class="p" id="msg__msgex3"><a name="msg__msgex3"><!-- --></a>The following example lists messages in the message queue
|
||
|
for the current user: <div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code
|
||
|
example disclaimer</a> for important legal information.</div>
|
||
|
</div>
|
||
|
<pre> // The message queue is on this iSeries.
|
||
|
AS400 sys = new AS400(mySystem.myCompany.com);
|
||
|
|
||
|
// Create the message queue object.
|
||
|
// This object will represent the
|
||
|
// queue for the current user.
|
||
|
MessageQueue queue = new MessageQueue(sys, MessageQueue.CURRENT);
|
||
|
|
||
|
// Get the list of messages currently
|
||
|
// in this user's queue.
|
||
|
Enumeration e = queue.getMessages();
|
||
|
|
||
|
// Print each message in the queue.
|
||
|
while (e.hasMoreElements())
|
||
|
{
|
||
|
QueuedMessage msg = e.getNextElement();
|
||
|
System.out.println(msg.getText());
|
||
|
}</pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</body>
|
||
|
</html>
|