All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.access.MessageQueue

java.lang.Object
   |
   +----com.ibm.as400.access.MessageQueue

public class MessageQueue
extends Object
implements Serializable
The MessageQueue class represents an AS/400 message queue.

For example:

 MessageQueue queue = new MessageQueue( as400, MessageQueue.CURRENT );
 Enumeration e = queue.getMessages ();
 while (e.hasMoreElements ())
 {
    QueuedMessage message = (QueuedMessage) e.nextElement ();
    System.out.println (message.getText ());
 }
 

MessageQueue objects generate the following events:

See Also:
QueuedMessage

Variable Index

 o ALL
Constant referring to all messages in the message queue.
 o ANY
Constant referring to any message in the message queue.
 o BYKEY
Constant referring to a message identified by a key.
 o COMPLETION
Constant referring to completion messages.
 o COPY
Constant referring to the sender's copy of a previously sent inquiry message.
 o CURRENT
Constant referring to the current user's message queue.
 o DIAGNOSTIC
Constant referring to diagnostic messages.
 o FIRST
Constant referring to the first message in the message queue.
 o INFORMATIONAL
Constant referring to informational messages.
 o INQUIRY
Constant referring to inquiry messages.
 o KEEP_UNANSWERED
Constant referring to all messages in the message queue except unanswered inquiry and unanswered senders' copy messages.
 o LAST
Constant referring to the last message in the message queue.
 o MESSAGES_NEED_REPLY
Constant referring to messages that need a reply.
 o MESSAGES_NO_NEED_REPLY
Constant referring to messages that do not need a reply.
 o NEW
Constant referring to all new messages in the message queue.
 o NEXT
Constant referring to the next message in the message queue.
 o OLD
Constant referring to all old messages in the message queue.
 o PREVIOUS
Constant referring to the previous message in the message queue.
 o REMOVE
Constant indicating that the message should be removed from the message queue.
 o SAME
Constant indicating that the message should remain in the message queue without changing its new or old designation.
 o SENDERS_COPY_NEED_REPLY
Constant referring to the sender's copies of messages that need replies.

Constructor Index

 o MessageQueue()
Constructs a MessageQueue object.
 o MessageQueue(AS400)
Constructs a MessageQueue object.
 o MessageQueue(AS400, String)
Constructs a MessageQueue object.

Method Index

 o addPropertyChangeListener(PropertyChangeListener)
Adds a listener to be notified when the value of any bound property is changed.
 o addVetoableChangeListener(VetoableChangeListener)
Adds a listener to be notified when the value of any constrained property is changed.
 o getLength()
Returns the number of messages in the list that was most recently retrieved from the AS/400 (the last call to getMessages()).
 o getMessages()
Returns a list of messages in the message queue.
 o getPath()
Returns the fully qualified integrated file system path name of the message queue.
 o getSelection()
Returns the selection that describes which messages are returned.
 o getSeverity()
Returns the severity of the messages to be returned.
 o getSystem()
Returns the AS/400 system on which the message queue exists.
 o receive(byte[])
Receives a message from the message queue by key.
 o receive(byte[], int, String, String)
Receives a message from the message queue.
 o remove()
Remove all messages from the message queue.
 o remove(byte[])
Removes a message from the message queue by key.
 o remove(String)
Remove messages from the message queue by type.
 o removePropertyChangeListener(PropertyChangeListener)
Removes a property change listener from the listener list.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes a vetoable change listener from the listener list.
 o reply(byte[], String)
Replies to a message.
 o sendInformational(String)
Sends an informational message to the message queue.
 o sendInformational(String, String)
Sends an informational message to the message queue.
 o sendInformational(String, String, byte[])
Sends an informational message to the message queue.
 o sendInquiry(String, String)
Sends an inquiry message to the message queue.
 o sendInquiry(String, String, byte[], String)
Sends an inquiry message to the message queue.
 o sendInquiry(String, String, String)
Sends an inquiry message to the message queue.
 o setPath(String)
Sets the fully qualified integrated file system path name of the message queue.
 o setSelection(String)
Sets the selection that describes which messages are returned.
 o setSeverity(int)
Sets the severity of the messages to be returned.
 o setSystem(AS400)
Sets the AS/400 system on which the message queue exists.

Variables

 o ALL
 public static final String ALL
Constant referring to all messages in the message queue.

 o ANY
 public static final String ANY
Constant referring to any message in the message queue.

 o BYKEY
 public static final String BYKEY
Constant referring to a message identified by a key.

 o COMPLETION
 public static final String COMPLETION
Constant referring to completion messages.

 o COPY
 public static final String COPY
Constant referring to the sender's copy of a previously sent inquiry message.

 o CURRENT
 public static final String CURRENT
Constant referring to the current user's message queue.

 o DIAGNOSTIC
 public static final String DIAGNOSTIC
Constant referring to diagnostic messages.

 o FIRST
 public static final String FIRST
Constant referring to the first message in the message queue.

 o INFORMATIONAL
 public static final String INFORMATIONAL
Constant referring to informational messages.

 o INQUIRY
 public static final String INQUIRY
Constant referring to inquiry messages.

 o KEEP_UNANSWERED
 public static final String KEEP_UNANSWERED
Constant referring to all messages in the message queue except unanswered inquiry and unanswered senders' copy messages.

 o LAST
 public static final String LAST
Constant referring to the last message in the message queue.

 o MESSAGES_NEED_REPLY
 public static final String MESSAGES_NEED_REPLY
Constant referring to messages that need a reply.

 o MESSAGES_NO_NEED_REPLY
 public static final String MESSAGES_NO_NEED_REPLY
Constant referring to messages that do not need a reply.

 o NEW
 public static final String NEW
Constant referring to all new messages in the message queue. New messages are those that have not been received.

 o NEXT
 public static final String NEXT
Constant referring to the next message in the message queue.

 o OLD
 public static final String OLD
Constant referring to all old messages in the message queue. Old messages are those that have already been received.

 o PREVIOUS
 public static final String PREVIOUS
Constant referring to the previous message in the message queue.

 o REMOVE
 public static final String REMOVE
Constant indicating that the message should be removed from the message queue.

 o SAME
 public static final String SAME
Constant indicating that the message should remain in the message queue without changing its new or old designation.

 o SENDERS_COPY_NEED_REPLY
 public static final String SENDERS_COPY_NEED_REPLY
Constant referring to the sender's copies of messages that need replies.

Constructors

 o MessageQueue
 public MessageQueue()
Constructs a MessageQueue object. The system property needs to be set before using any method requiring a connection to the AS/400.

 o MessageQueue
 public MessageQueue(AS400 system)
Constructs a MessageQueue object.

Depending on how the AS400 object was constructed, the user may need to be prompted for the system name, user ID, or password when any method requiring a connection to the AS/400 is used.

Parameters:
system - The AS/400 system on which the message queue exists. This value cannot be null.
 o MessageQueue
 public MessageQueue(AS400 system,
                     String path)
Constructs a MessageQueue object.

Depending on how the AS400 object was constructed, the user may need to be prompted for the system name, user ID, or password when any method requiring a connection to the AS/400 is used.

Parameters:
system - The AS/400 system on which the message queue exists. This value cannot be null.
path - The fully qualified integrated file system path name of the message queue, or CURRENT to refer to the user's default message queue. This value cannot be null.

Methods

 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener to be notified when the value of any bound property is changed. The propertyChange() method will be be called.

Parameters:
listener - The PropertyChangeListener.
 o addVetoableChangeListener
 public void addVetoableChangeListener(VetoableChangeListener listener)
Adds a listener to be notified when the value of any constrained property is changed. The vetoableChange() method will be called.

Parameters:
listener - The VetoableChangeListener.
 o getLength
 public int getLength()
Returns the number of messages in the list that was most recently retrieved from the AS/400 (the last call to getMessages()).

Returns:
The number of messages, or 0 if no list has been retrieved.
 o getMessages
 public Enumeration getMessages() throws AS400Exception, AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException
Returns a list of messages in the message queue. A valid AS/400 system must be provided before this call is made.

Returns:
An Enumeration of QueuedMessage objects.
Throws: AS400Exception
If the AS/400 system returns an error message.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ObjectDoesNotExistException
If the AS/400 object does not exist.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o getPath
 public String getPath()
Returns the fully qualified integrated file system path name of the message queue.

Returns:
The fully qualified integrated file system path name of the message queue, or CURRENT to refer to the user's default message queue.
 o getSelection
 public String getSelection()
Returns the selection that describes which messages are returned.

Returns:
The selection.
 o getSeverity
 public int getSeverity()
Returns the severity of the messages to be returned.

Returns:
The severity of the messages to be returned.
 o getSystem
 public AS400 getSystem()
Returns the AS/400 system on which the message queue exists.

Returns:
The AS/400 system on which the message queue exists.
 o receive
 public QueuedMessage receive(byte key[]) throws AS400Exception, AS400SecurityException, IOException, ObjectDoesNotExistException, ErrorCompletingRequestException, InterruptedException
Receives a message from the message queue by key. The message is removed from the message queue.
Note: Receive is the only method that fills in most of the QueuedMessage fields.

Use getMessages () to return a message enumeration. The key parameter required by the receive method is returned from the AS/400 by QueuedMessage.getKey ().

Parameters:
key - The message key.
Returns:
The message.
Throws: AS400Exception
If the AS/400 system returns an error message.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ObjectDoesNotExistException
If the AS/400 object does not exist.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
See Also:
getMessages, getKey, QueuedMessage
 o receive
 public QueuedMessage receive(byte key[],
                              int wait,
                              String action,
                              String type) throws AS400Exception, AS400SecurityException, IOException, ObjectDoesNotExistException, ErrorCompletingRequestException, InterruptedException
Receives a message from the message queue.
Note: Receive is the only method that fills in most of the QueuedMessage fields.

Use getMessages () to return a message enumeration. The key parameter required by the receive method is returned from the AS/400 by QueuedMessage.getKey ().

Parameters:
key - The message key, or null if no message key is needed. This may be required, optional, or disallowed depending on the specified type.
wait - The amount of time to wait for the operation to complete.
action - The action to take after the message is received. Valid values are:
  • OLD - Keep the message in the message queue and mark it as an old message. You can receive the message again only by using the message key or by specifying the message type NEXT, PREVIOUS, FIRST, or LAST.
  • REMOVE - Remove the message from the message queue. The message key is no longer valid, so you cannot receive the message again.
  • SAME - Keep the message in the message queue without changing its new or old designation. SAME lets you receive the message again later without using the message key.
type - The type of message to return. Valid values are:
  • ANY - Receives a message of any type except sender's copy. The message key is optional.
  • COMPLETION - Receives a completion message. The message key is optional.
  • COPY - Receives the sender's copy of a previously sent inquiry message. The message key is required.
  • DIAGNOSTIC - Receives a diagnostic message. The message key is optional.
  • FIRST - Receives the first new or old message in the queue. The message key is disallowed.
  • INFORMATIONAL - Receives an informational message. The message key is optional.
  • INQUIRY - Receives an inquiry message. If the action is REMOVE and a reply to the inquiry message has not been sent yet, the default reply is automatically sent when the inquiry message is received. The message key is optional.
  • LAST - Receives the last new or old message in the queue. The message key is disallowed.
  • NEXT - Receives the next new or old message after the message with the specified key. You can use the special value TOP for the message key. TOP designates the message at the top of the message queue. The message key is required.
  • PREVIOUS - Receives the new or old message before the message with the specified key. The message key is required.
  • REPLY - Receives the reply to an inquiry message. For the message key, you can use the key to the sender's copy of the inquiry or notify message. The message key is optional.
Returns:
The message.
Throws: AS400Exception
If the AS/400 system returns an error message.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ObjectDoesNotExistException
If the AS/400 object does not exist.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
See Also:
getMessages, getKey, QueuedMessage
 o remove
 public void remove() throws AS400Exception, AS400SecurityException, IOException, ObjectDoesNotExistException, ErrorCompletingRequestException, InterruptedException
Remove all messages from the message queue.

Throws: AS400Exception
If the AS/400 system returns an error message.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ObjectDoesNotExistException
If the AS/400 object does not exist.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o remove
 public void remove(byte key[]) throws AS400Exception, AS400SecurityException, IOException, ObjectDoesNotExistException, ErrorCompletingRequestException, InterruptedException
Removes a message from the message queue by key.

Parameters:
key - The message key.
Throws: AS400Exception
If the AS/400 system returns an error message.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ObjectDoesNotExistException
If the AS/400 object does not exist.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o remove
 public void remove(String type) throws AS400Exception, AS400SecurityException, IOException, ObjectDoesNotExistException, ErrorCompletingRequestException, InterruptedException
Remove messages from the message queue by type.

Parameters:
type - The type of message to remove. Valid values are:
  • ALL - All messages in the message queue.
  • KEEP_UNANSWERED - All messages in the message queue except unanswered inquiry and unanswered senders' copy messages.
  • NEW - All new messages in the message queue. New messages are those that have not been received.
  • OLD - All old messages in the message queue. Old messages are those that have already been received.
Throws: AS400Exception
If the AS/400 system returns an error message.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ObjectDoesNotExistException
If the AS/400 object does not exist.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a property change listener from the listener list.

Parameters:
listener - The PropertyChangeListener.
 o removeVetoableChangeListener
 public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes a vetoable change listener from the listener list.

Parameters:
listener - The VetoableChangeListener.
 o reply
 public void reply(byte key[],
                   String reply) throws AS400Exception, AS400SecurityException, IOException, ObjectDoesNotExistException, ErrorCompletingRequestException, InterruptedException
Replies to a message.

Parameters:
key - The message key.
reply - The reply text.
Throws: AS400Exception
If the AS/400 system returns an error message.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ObjectDoesNotExistException
If the AS/400 object does not exist.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o sendInformational
 public void sendInformational(String id,
                               String file) throws AS400Exception, AS400SecurityException, IOException, ObjectDoesNotExistException, ErrorCompletingRequestException, InterruptedException
Sends an informational message to the message queue.

Parameters:
id - The message id.
file - The integrated file system path of the message file.
Throws: AS400Exception
If the AS/400 system returns an error message.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ObjectDoesNotExistException
If the AS/400 object does not exist.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o sendInformational
 public void sendInformational(String id,
                               String file,
                               byte substitutionData[]) throws AS400Exception, AS400SecurityException, IOException, ObjectDoesNotExistException, ErrorCompletingRequestException, InterruptedException
Sends an informational message to the message queue.

Parameters:
id - The message id.
file - The integrated file system path of the message file.
substitutionData - The substition data.
Throws: AS400Exception
If the AS/400 system returns an error message.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ObjectDoesNotExistException
If the AS/400 object does not exist.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o sendInformational
 public void sendInformational(String text) throws AS400Exception, AS400SecurityException, IOException, ObjectDoesNotExistException, ErrorCompletingRequestException, InterruptedException
Sends an informational message to the message queue.

Parameters:
text - The message text.
Throws: AS400Exception
If the AS/400 system returns an error message.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ObjectDoesNotExistException
If the AS/400 object does not exist.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o sendInquiry
 public void sendInquiry(String id,
                         String file,
                         String replyQueue) throws AS400Exception, AS400SecurityException, IOException, ObjectDoesNotExistException, ErrorCompletingRequestException, InterruptedException
Sends an inquiry message to the message queue.

Parameters:
id - The message id.
file - The integrated file system path of the message file.
replyQueue - The integrated file system path of the reply queue.
Throws: AS400Exception
If the AS/400 system returns an error message.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ObjectDoesNotExistException
If the AS/400 object does not exist.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o sendInquiry
 public void sendInquiry(String id,
                         String file,
                         byte substitutionData[],
                         String replyQueue) throws AS400Exception, AS400SecurityException, IOException, ObjectDoesNotExistException, ErrorCompletingRequestException, InterruptedException
Sends an inquiry message to the message queue.

Parameters:
id - The message id.
file - The integrated file system path of the message file.
substitutionData - The substition data.
replyQueue - The integrated file system path of the reply queue.
Throws: AS400Exception
If the AS/400 system returns an error message.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ObjectDoesNotExistException
If the AS/400 object does not exist.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o sendInquiry
 public void sendInquiry(String msg,
                         String replyQueue) throws AS400Exception, AS400SecurityException, IOException, ObjectDoesNotExistException, ErrorCompletingRequestException, InterruptedException
Sends an inquiry message to the message queue.

Parameters:
text - The message text.
replyQueue - The integrated file system path of the reply queue.
Throws: AS400Exception
If the AS/400 system returns an error message.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ObjectDoesNotExistException
If the AS/400 object does not exist.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o setPath
 public void setPath(String path) throws PropertyVetoException
Sets the fully qualified integrated file system path name of the message queue. The default is CURRENT.

Parameters:
path - The fully qualified integrated file system path name of the message queue, or CURRENT to refer to the user's default message queue.
Throws: PropertyVetoException
If the change is vetoed.
 o setSelection
 public void setSelection(String selection) throws PropertyVetoException
Sets the selection that describes which messages are returned. The default is ALL. This takes effect the next time that getMessages() is called.

Parameters:
selection - The selection that describes which messages are returned. Valid values are:
  • ALL
  • MESSAGES_NEED_REPLY
  • MESSAGES_NO_NEED_REPLY
  • SENDERS_COPY_NEED_REPLY
This value cannot be null.
Throws: PropertyVetoException
If the change is vetoed.
 o setSeverity
 public void setSeverity(int severity) throws PropertyVetoException
Sets the severity of the messages to be returned. All messages of the specified severity and greater are returned. The default is 0. This takes effect the next time that getMessages() is called.

Parameters:
severity - The severity of the messages to be returned.
Throws: ExtendedIllegalArgumentException
If the argument passed is not valid.
Throws: PropertyVetoException
If the change is vetoed.
 o setSystem
 public void setSystem(AS400 system) throws PropertyVetoException
Sets the AS/400 system on which the message queue exists.

Parameters:
system - The AS/400 system on which the message queue exists. This value cannot be null.
Throws: PropertyVetoException
If the change is vetoed.

All Packages  Class Hierarchy  This Package  Previous  Next  Index