com.ibm.mq.pcf

Class PCFMessageAgent

  1. java.lang.Object
  2. extended bycom.ibm.mq.jmqi.JmqiObject
  3. extended bycom.ibm.mq.pcf.PCFAgent
  4. extended bycom.ibm.mq.pcf.PCFMessageAgent

  1. public class PCFMessageAgent
  2. extends PCFAgent
General-purpose agent for sending PCF queries to a queue manager. Like the PCFAgent it extends, a PCFMessageAgent maintains a single queue manager connection and provides a simple method for sending PCF requests and returning the set of response messages. The PCFMessageAgent uses the PCFMessage class for requests and replies, which avoids exposure to the details of underlying PCF header structures. The PCFMessageAgent also provides the capability to check the header contents of a PCF response and throw a PCFException if the response indicates an error.

The following example uses a PCFMessageAgent to obtain the list of local queues on the queue manager.

     import com.ibm.mq.pcf.*;

     ...

     try
     {
       PCFMessageAgent agent = new PCFMessageAgent ("localhost", 1414, "CLIENT");
       PCFMessage   request = new PCFMessage (CMQCFC.MQCMD_INQUIRE_Q_NAMES);

       request.addParameter (CMQC.MQCA_Q_NAME, "*");
       request.addParameter (CMQC.MQIA_Q_TYPE, MQC.MQQT_LOCAL);

       PCFMessage []   responses = agent.send (request);
       String []   names = (String []) responses [0].getParameterValue (CMQCFC.MQCACF_Q_NAMES);

       for (int i = 0; i < names.length; i++)
       {
         System.out.println ("Queue: " + names [i]);
       }
     }

     catch (PCFException pcfe)
     {
       System.err.println ("PCF error: " + pcfe);
     }

     catch (MQException mqe)
     {
       System.err.println (mqe);
     }

     catch (IOException ioe)
     {
       System.err.println (ioe);
     }

 

Field Summary

Fields inherited from class com.ibm.mq.pcf.PCFAgent
MAXIMUM_ALLOWED_PREFIX_LENGTH, replyQueueName
Fields inherited from class com.ibm.mq.jmqi.JmqiObject
COMP_JM, COMP_JN, COMP_JO

Constructor Summary

Constructor and Description
PCFMessageAgent()
Default constructor.
PCFMessageAgent(MQQueueManager qmanager)
Initializes a new PCFMessageAgent with an existing queue manager connection.
PCFMessageAgent(java.lang.String qmanager)
Initializes a new PCFMessageAgent with a bindings connection to a queue manager.
PCFMessageAgent(java.lang.String host,int port,java.lang.String channel)
Initializes a new PCFMessageAgent with a client connection to a queue manager.

Method Summary

Modifier and Type Method and Description
  1. PCFMessage[]
send(PCFMessage request)
Sends a PCF request to the connected queue manager and returns the responses.
  1. PCFMessage[]
send(PCFMessage request,boolean check)
Deprecated. Use setCheckResponses and send(com.ibm.mq.pcf.PCFMessage)
  1. PCFMessage[]
send(PCFMessage request,boolean check,boolean usePlatformSettings)
Deprecated. Use setCheckResponses/setUsePlatformSettings and send(com.ibm.mq.pcf.PCFMessage)
  1. void
setCheckResponses(boolean option)
If this option is set, the send method throws a PCFException if the responses include a PCF message with the reason code MQRCCF_COMMAND_FAILED in the MQCFH header.
  1. void
setUsePlatformSettings(boolean option)
If this option is set, the send method alters the MQCFH contained within the PCFMessage request if necessary to match the platform of the connected queue manager.
Methods inherited from class com.ibm.mq.pcf.PCFAgent
connect, connect, connect, connect, connect, connect, disconnect, getCommandLevel, getExpiry, getModelQueueName, getPlatform, getQManagerName, getReplyQueueName, getReplyQueuePrefix, getWaitInterval, send, setCharacterSet, setEncoding, setModelQueueName, setReplyQueuePrefix, setWaitInterval, setWaitInterval
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

PCFMessageAgent

  1. public PCFMessageAgent()
Default constructor. Initializes a new PCFMessageAgent with no queue manager connection.

PCFMessageAgent

  1. public PCFMessageAgent(MQQueueManager qmanager)
  2. throws MQException
Initializes a new PCFMessageAgent with an existing queue manager connection.
Parameters:
qmanager - an existing queue manager connection
Throws:
MQException - if the queue manager cannot be accessed

PCFMessageAgent

  1. public PCFMessageAgent(java.lang.String host,
  2. int port,
  3. java.lang.String channel)
  4. throws MQException
Initializes a new PCFMessageAgent with a client connection to a queue manager.
Parameters:
host - the hostname or IP address where the queue manager resides
port - the port on which the queue manager listens for incoming channel connections
channel - the client channel to use for the connection
Throws:
MQException - if the connection cannot be established

PCFMessageAgent

  1. public PCFMessageAgent(java.lang.String qmanager)
  2. throws MQException
Initializes a new PCFMessageAgent with a bindings connection to a queue manager.
Parameters:
qmanager - the name of the queue manager
Throws:
MQException - if the connection cannot be established

Method Detail

send

  1. public PCFMessage[] send(PCFMessage request)
  2. throws PCFException
  3. MQException
  4. java.io.IOException
Sends a PCF request to the connected queue manager and returns the responses.
Parameters:
request - the PCF request message
Returns:
an array of PCF response messages. A single PCF request can generate multiple replies.
Throws:
PCFException - if the response indicates an error in PCF processing
MQException - if there is a problem with the request or response
java.io.IOException - if there is a problem with reading or writing
See Also:

send

  1. public PCFMessage[] send(PCFMessage request,
  2. boolean check)
  3. throws PCFException
  4. MQException
  5. java.io.IOException
Deprecated. Use setCheckResponses and send(com.ibm.mq.pcf.PCFMessage)
Sends a PCF request to the connected queue manager and returns the responses.
Parameters:
request - the PCF request message
check - if set, the agent will check the reason code in the MQCFH of the responses and generate a PCFException if MQRCCF_COMMAND_FAILED appears
Returns:
an array of PCF response messages. A single PCF request can generate multiple replies.
Throws:
PCFException - if the responses include MQRCCF_COMMAND_FAILED
MQException - if there is a problem with the request or response
java.io.IOException - if there is a problem with reading or writing
See Also:

send

  1. public PCFMessage[] send(PCFMessage request,
  2. boolean check,
  3. boolean usePlatformSettings)
  4. throws PCFException
  5. MQException
  6. java.io.IOException
Deprecated. Use setCheckResponses/setUsePlatformSettings and send(com.ibm.mq.pcf.PCFMessage)
Sends a PCF request to the connected queue manager and returns the responses.
Parameters:
request - the PCF request message
check - if set, the agent will check the reason code in the MQCFH of the responses and generate a PCFException if MQRCCF_COMMAND_FAILED appears
Returns:
an array of PCF response messages. A single PCF request can generate multiple replies.
Throws:
PCFException - if the responses include MQRCCF_COMMAND_FAILED
MQException - if there is a problem with the request or response
java.io.IOException - if there is a problem with reading or writing
See Also:

setCheckResponses

  1. public void setCheckResponses(boolean option)
If this option is set, the send method throws a PCFException if the responses include a PCF message with the reason code MQRCCF_COMMAND_FAILED in the MQCFH header. By default, this option is set.

setUsePlatformSettings

  1. public void setUsePlatformSettings( boolean option)
If this option is set, the send method alters the MQCFH contained within the PCFMessage request if necessary to match the platform of the connected queue manager. This occurs, for example, if the connected queue manager is a z/OS queue manager and the request MQCFH contains type MQCFT_COMMAND; the agent will change the type to type MQCFT_COMMAND_XR. By default, this option is set.