當前位置: 首頁>>代碼示例>>Java>>正文


Java JMSException.setLinkedException方法代碼示例

本文整理匯總了Java中javax.jms.JMSException.setLinkedException方法的典型用法代碼示例。如果您正苦於以下問題:Java JMSException.setLinkedException方法的具體用法?Java JMSException.setLinkedException怎麽用?Java JMSException.setLinkedException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.jms.JMSException的用法示例。


在下文中一共展示了JMSException.setLinkedException方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: create

import javax.jms.JMSException; //導入方法依賴的package包/類
/**
 * Creates or passes through a JMSException to be thrown to the client.
 *
 * In the event that the exception passed to this method is already a
 * JMSException it is passed through unmodified, otherwise a new JMSException
 * is created with the given message and the cause is set to the given
 * cause Throwable instance.
 *
 * @param message
 *        The message value to set when a new JMSException is created.
 * @param cause
 *        The exception that caused this error state.
 *
 * @return a JMSException instance.
 */
public static JMSException create(String message, Throwable cause) {
    if (cause instanceof JMSException) {
        return (JMSException) cause;
    }

    if (cause.getCause() instanceof JMSException) {
        return (JMSException) cause.getCause();
    }

    if (message == null || message.isEmpty()) {
        message = cause.getMessage();
        if (message == null || message.isEmpty()) {
            message = cause.toString();
        }
    }

    JMSException exception = new JMSException(message);
    if (cause instanceof Exception) {
        exception.setLinkedException((Exception) cause);
    }
    exception.initCause(cause);
    return exception;
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:39,代碼來源:JMSExceptionSupport.java

示例2: setJMSCorrelationID

import javax.jms.JMSException; //導入方法依賴的package包/類
@Override
public void setJMSCorrelationID(String correlationID) throws JMSException {
    try {
        correlationId = correlationID.getBytes("iso-8859-1");
    } catch (UnsupportedEncodingException e) {
        final JMSException jmsException = new JMSException("Failed to get bytes from correlationID string");
        jmsException.setLinkedException(e);
        throw jmsException;
    }
}
 
開發者ID:dajudge,項目名稱:testee.fi,代碼行數:11,代碼來源:AbstractMessageImpl.java

示例3: getJMSCorrelationID

import javax.jms.JMSException; //導入方法依賴的package包/類
@Override
public String getJMSCorrelationID() throws JMSException {
    try {
        return new String(correlationId, "iso-8859-1");
    } catch (UnsupportedEncodingException e) {
        final JMSException jmsException = new JMSException("Failed to get string from correlationID bytes");
        jmsException.setLinkedException(e);
        throw jmsException;
    }
}
 
開發者ID:dajudge,項目名稱:testee.fi,代碼行數:11,代碼來源:AbstractMessageImpl.java

示例4: receive

import javax.jms.JMSException; //導入方法依賴的package包/類
public Message receive(long timeout) throws JMSException {
    try {
        Thread.sleep(timeout);
    } catch (InterruptedException ex) {
        logger.warn(ex.getMessage(), ex);

        JMSException jmsException = new JMSException(ex.getMessage());
        jmsException.setLinkedException(ex);
        throw jmsException;
    }

    return getMessage();
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:14,代碼來源:ProxyMessageConsumer.java


注:本文中的javax.jms.JMSException.setLinkedException方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。