本文整理汇总了Java中com.ibm.mq.MQException.getReason方法的典型用法代码示例。如果您正苦于以下问题:Java MQException.getReason方法的具体用法?Java MQException.getReason怎么用?Java MQException.getReason使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.mq.MQException
的用法示例。
在下文中一共展示了MQException.getReason方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleException
import com.ibm.mq.MQException; //导入方法依赖的package包/类
/**
* Handles exceptions from MQ. Some JMS exceptions are treated as retriable meaning that the
* connector can keep running and just trying again is likely to fix things.
*
* @throws RetriableException Operation failed, but connector should continue to retry.
* @throws ConnectException Operation failed and connector should stop.
*/
private void handleException(Throwable exc) throws ConnectException, RetriableException {
boolean isRetriable = false;
boolean mustClose = true;
int reason = -1;
// Try to extract the MQ reason code to see if it's a retriable exception
Throwable t = exc.getCause();
while (t != null) {
if (t instanceof MQException) {
MQException mqe = (MQException)t;
log.error("MQ error: CompCode {}, Reason {}", mqe.getCompCode(), mqe.getReason());
reason = mqe.getReason();
break;
}
t = t.getCause();
}
switch (reason)
{
// These reason codes indicate that the connection needs to be closed, but just retrying later
// will probably recover
case MQConstants.MQRC_BACKED_OUT:
case MQConstants.MQRC_CHANNEL_NOT_AVAILABLE:
case MQConstants.MQRC_CONNECTION_BROKEN:
case MQConstants.MQRC_HOST_NOT_AVAILABLE:
case MQConstants.MQRC_NOT_AUTHORIZED:
case MQConstants.MQRC_Q_MGR_NOT_AVAILABLE:
case MQConstants.MQRC_Q_MGR_QUIESCING:
case MQConstants.MQRC_Q_MGR_STOPPING:
case MQConstants.MQRC_UNEXPECTED_ERROR:
isRetriable = true;
break;
// These reason codes indicates that the connect is still OK, but just retrying later
// will probably recover - possibly with administrative action on the queue manager
case MQConstants.MQRC_Q_FULL:
case MQConstants.MQRC_PUT_INHIBITED:
isRetriable = true;
mustClose = false;
break;
}
if (mustClose) {
close();
}
if (isRetriable) {
throw new RetriableException(exc);
}
throw new ConnectException(exc);
}
示例2: handleException
import com.ibm.mq.MQException; //导入方法依赖的package包/类
/**
* Handles exceptions from MQ. Some JMS exceptions are treated as retriable meaning that the
* connector can keep running and just trying again is likely to fix things.
*/
private void handleException(Throwable exc) throws ConnectException, RetriableException {
boolean isRetriable = false;
boolean mustClose = true;
int reason = -1;
// Try to extract the MQ reason code to see if it's a retriable exception
Throwable t = exc.getCause();
while (t != null) {
if (t instanceof MQException) {
MQException mqe = (MQException)t;
log.error("MQ error: CompCode {}, Reason {} {}", mqe.getCompCode(), mqe.getReason(),
MQConstants.lookupReasonCode(mqe.getReason()));
reason = mqe.getReason();
break;
}
t = t.getCause();
}
switch (reason)
{
// These reason codes indicate that the connection needs to be closed, but just retrying later
// will probably recover
case MQConstants.MQRC_BACKED_OUT:
case MQConstants.MQRC_CHANNEL_NOT_AVAILABLE:
case MQConstants.MQRC_CONNECTION_BROKEN:
case MQConstants.MQRC_HOST_NOT_AVAILABLE:
case MQConstants.MQRC_NOT_AUTHORIZED:
case MQConstants.MQRC_Q_MGR_NOT_AVAILABLE:
case MQConstants.MQRC_Q_MGR_QUIESCING:
case MQConstants.MQRC_Q_MGR_STOPPING:
case MQConstants.MQRC_UNEXPECTED_ERROR:
isRetriable = true;
break;
// These reason codes indicates that the connect is still OK, but just retrying later
// will probably recover - possibly with administrative action on the queue manager
case MQConstants.MQRC_GET_INHIBITED:
isRetriable = true;
mustClose = false;
break;
}
if (mustClose) {
closeInternal();
}
if (isRetriable) {
throw new RetriableException(exc);
}
throw new ConnectException(exc);
}