Joke Collection Website - Blessing messages - How does mq java judge that the queue is empty?

How does mq java judge that the queue is empty?

MQ exception

This class contains definitions of WebSphere MQ completion code and error code constants. Constants starting with MQCC_ are WebSphere MQ completion codes, while constants starting with MQRC_ are WebSphere MQ reason codes. As long as WebSphere MQ appears

Error, MQException will be given.

MQGetMessageOptions

This class contains options to control the behavior of the MQQueue.get () method.

MQManagedObject

This class is a superclass of MQQueueManager, MQQueue and MQProcess classes. It provides the ability to query and set the properties of these resources.

-Solutions.

Get it once and get the 2033 error, that is, there is no news that meets your requirements.

Using PCF to query queue data:

/**

* @ Returns the current depth of the current connection queue.

* @ throws an exception

*/

Public QueueInfo queryQueueInfo () threw an exception {

If (! check status 2(this . queue manager)){

Throws a new IllegalStateException ("Not connected to the queue manager." );

}

PCFMessageAgent proxy = null

Try {

agent = new PCFMessageAgent(this . queue manager);

//Query the queue name & current depth.

int[] attrs = {

CMQC。 MQCA_Q_NAME。 MQIA _ current _ Q _ depth,

CMQC。 MQIA_OPEN_INPUT_COUNT,CMQC。 MQIA_OPEN_OUTPUT_COUNT

CMQC。 MQIA_Q_TYPE,CMQC。 MQIA_DEFINITION_TYPE。 MQIA_INHIBIT_GET,

CMQC。 MQIA _ INHIBIT _ PUT };

PCFParameter[] parameter = {

New MQCFST(CMQC. MQCA_Q_NAME,getInputQueue()。 getText()。 trim()),

New MQCFIL(CMQCFC. MQIACF_Q_ATTRS,ATTRS)};

// logger.log ("Query the current depth of the current queue." );

MQ message[]responses = agent . send(cmq CFC。 MQCMD_INQUIRE_Q, parameter);

queue info info = new queue info();

for(int I = 0; I < Response. Length; i++) {

MQ cfh cfh = new MQ cfh(responses[I]);

//check the PCF header (MQCFH) in the response message.

if (cfh.reason == 0) {

String name = "";

Integer depth = new integer (0);

for(int j = 0; J & ltcfh.parameterCountj++) {// Extract what we want from the returned attributes.

PCF parameter p = PCF parameter . next parameter(responses[I]);

switch (p.getParameter()) {

Case CMQC. MQCA_Q_NAME:

name =(String)p . getvalue();

info.name = name

Break;

Case CMQC. MQIA _ Current _ Q _ Depth:

Depth = (integer) p.getvalue ();

info . depth = depth . int value();

Break;

Case CMQC. MQIA _ Open _ Input _ Count:

Integer input count =(Integer)p . getvalue();

info . input count = input count . int value();

Break;

Case CMQC. MQIA _ Open _ Output _ Count:

Integer output count =(Integer)p . getvalue();

info . output count = output count . int value();

Break;

Case CMQC. MQIA_Q_TYPE:

info.type = ((Integer) p.getValue())。 int value();

Break;

Case CMQC. MQIA_DEFINITION_TYPE:

info . definition type =((Integer)p . getvalue())。 int value();

Break;

Case CMQC. MQIA _ Suppress _ Output:

info . putnotallowed =((Integer)p . getvalue())。 int value()= = 1;

Break; Case CMQC. MQIA_INHIBIT_GET:

info . getnotallowed =((Integer)p . getvalue())。 int value()= = 1;

Default value:

}

}

//system . out . println(" Queue "+name+" curdepth "+depth);

Return information;

} Otherwise {

System.out.println("PCF error: \ n "+cfh);

//Traverse the return parameter that describes the error

for(int j = 0; j & ltcfh.parameterCountj++) {

system . out . println(PCF parameter . next parameter(responses[0]);

}

Throws a new exception ("PCFError [reason:"+CFH. reason+"]");

}

}

Returns null

Catch (exception e) {

Throw e;

} Finally {

If (agent! = null) {

Try {

agent . disconnect();

Catch (exception e) {

logger . log(e);

}

}

}