亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? jmsmessageconsumer.java

?? 一個java方面的消息訂閱發送的源碼
?? JAVA
字號:
/**
 * Redistribution and use of this software and associated documentation
 * ("Software"), with or without modification, are permitted provided
 * that the following conditions are met:
 *
 * 1. Redistributions of source code must retain copyright
 *    statements and notices.  Redistributions must also contain a
 *    copy of this document.
 *
 * 2. Redistributions in binary form must reproduce the
 *    above copyright notice, this list of conditions and the
 *    following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. The name "Exolab" must not be used to endorse or promote
 *    products derived from this Software without prior written
 *    permission of Exoffice Technologies.  For written permission,
 *    please contact info@exolab.org.
 *
 * 4. Products derived from this Software may not be called "Exolab"
 *    nor may "Exolab" appear in their names without prior written
 *    permission of Exoffice Technologies. Exolab is a registered
 *    trademark of Exoffice Technologies.
 *
 * 5. Due credit should be given to the Exolab Project
 *    (http://www.exolab.org/).
 *
 * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
 * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * Copyright 2000-2005 (C) Exoffice Technologies Inc. All Rights Reserved.
 *
 * $Id: JmsMessageConsumer.java,v 1.2 2005/03/18 03:36:37 tanderson Exp $
 */
package org.exolab.jms.client;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.Destination;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.exolab.jms.message.MessageImpl;


/**
 * Client implementation of the <code>javax.jms.MessageConsumer</code>
 * interface
 *
 * @author <a href="mailto:jima@comware.com.au">Jim Alateras</a>
 * @author <a href="mailto:tma@netspace.net.au">Tim Anderson</a>
 * @version $Revision: 1.2 $ $Date: 2005/03/18 03:36:37 $
 */
class JmsMessageConsumer
        implements MessageListener, MessageConsumer {

    /**
     * The session which created this
     */
    private JmsSession _session = null;

    /**
     * The consumer's identity, allocated by the server
     */
    private final long _consumerId;

    /**
     * The destination to receive messages from
     */
    private final Destination _destination;

    /**
     * A message listener may be assigned to this session, for asynchronous
     * message delivery.
     */
    private MessageListener _messageListener = null;

    /**
     * The message selector, for filtering messages. May be <code>null</code>
     */
    private String _selector = null;

    /**
     * Indicates if the session is closed
     */
    private volatile boolean _closed = false;

    /**
     * This is the last time that the listener had been set through {@link
     * #setMessageListener}
     */
    private long _listenerSetTimestamp = 0;

    /**
     * This is the last message id asynchronously delivered to the listener.
     */
    private String _lastMessageDelivered;

    /**
     * The logger
     */
    private static final Log _log =
            LogFactory.getLog(JmsMessageConsumer.class);


    /**
     * Construct a new <code>JmsMessageProducer</code>.
     *
     * @param session     the session responsible for the consumer
     * @param consumerId  the identity of this consumer
     * @param destination the destination to receive messages from
     * @param selector    the message selector. May be <code>null</code
     */
    public JmsMessageConsumer(JmsSession session, long consumerId,
                              Destination destination, String selector) {
        if (session == null) {
            throw new IllegalArgumentException("Argument 'session' is null");
        }
        if (destination == null) {
            throw new IllegalArgumentException(
                    "Argument 'destination' is null");
        }
        _session = session;
        _consumerId = consumerId;
        _destination = destination;
        _selector = selector;
    }

    /**
     * Return the message consumer's message selector expression
     *
     * @return the selector expression, or <code>null</code> if one isn't set
     */
    public String getMessageSelector() {
        return _selector;
    }

    /**
     * Return the consumer's listener
     *
     * @return the listener for the consumer, or <code>null</code> if there
     *         isn't one set
     */
    public MessageListener getMessageListener() {
        return _messageListener;
    }

    /**
     * Set the consumer's listener
     *
     * @param listener the message listener, or <code>null</code> to deregister
     *                 an existing listener
     * @throws JMSException if the listener cannot be set
     */
    public void setMessageListener(MessageListener listener)
            throws JMSException {
        // if listener is not null then enable asynchronous delivery
        // otherwise disable it
        if (listener != null) {
            if (_messageListener == null) {
                // previously asynchronouse messaging was disabled
                _listenerSetTimestamp = System.currentTimeMillis();
                _messageListener = listener;
                _session.setMessageListener(this);
            } else {
                // asynch message deliver is enabled, just changing the
                // client side receiving entity.
                _messageListener = listener;
            }
        } else {
            if (_messageListener != null) {
                _session.removeMessageListener(this);
                _messageListener = listener;
            }
        }

        // reset the lastMessageDelivered regardless what the value
        // of the listener is.
        _lastMessageDelivered = null;
    }

    /**
     * Receive the next message produced for this consumer. This call blocks
     * indefinitely until a message is produced or until this message consumer
     * is closed.
     *
     * @return the next message produced for this consumer, or <code>null</code>
     *         if this consumer is concurrently closed
     * @throws JMSException if the next message can't be received
     */
    public Message receive() throws JMSException {
        return retrieveMessage(0);
    }

    /**
     * Receive the next message that arrives within the specified timeout
     * interval. This call blocks until a message arrives, the timeout expires,
     * or this message consumer is closed. A timeout of zero never expires and
     * the call blocks indefinitely.
     *
     * @param timeout the timeout interval, in milliseconds
     * @return the next message produced for this consumer, or <code>null</code>
     *         if the timeout expires or the consumer concurrently closed
     * @throws JMSException if the next message can't be received
     */
    public Message receive(long timeout) throws JMSException {
        return retrieveMessage(timeout);
    }

    /**
     * Receive the next message if one is immediately available
     *
     * @return the next message produced for this consumer, or <code>null</code>
     *         if one is not available
     * @throws JMSException if the next message can't be received
     */
    public Message receiveNoWait() throws JMSException {
        return retrieveMessage(-1);
    }

    /**
     * Close the consumer. This call blocks until a receive or message listener
     * in progress has completed. A blocked consumer receive call returns
     * <code>null</code> when this consumer is closed.
     *
     * @throws JMSException if this consumer can't be closed
     */
    public synchronized void close() throws JMSException {
        if (!_closed) {
            try {
                _closed = true;
                _session.removeConsumer(this);

                // wake up any blocked threads and let them complete
                notifyAll();
            } finally {
                _messageListener = null;
                _session= null;
                _selector = null;
            }
        }
    }

    /**
     * Handles messages received asynchronously via the owning session, passing
     * them to the registered listener
     *
     * @param message the message received
     */
    public void onMessage(Message message) {
        try {
            if (_messageListener != null) {
                // drop all messages if they were received before the listener
                // had been set.
                long rcvd = message.getLongProperty("JMSXRcvTimestamp");
                if (rcvd < _listenerSetTimestamp) {
                    return;
                }

                // According to section 4.5.2 Asynchronous Delivery messages
                // delivered to consumers, through the MessageListener
                // interface in a transacted session must be treated the same
                // as synchronous delivery.
                // Need to set this field before we actually deliver the
                // message since the client can actually call
                // setMessageListener in onMessage()
                _lastMessageDelivered = ((MessageImpl) message).getId();
                _messageListener.onMessage(message);
            }
        } catch (JMSException exception) {
            //report the exception
            _log.error("Error in onMessage", exception);
        }
    }

    /**
     * Retrieve the next message for the consumer.
     *
     * @param wait the maximum time to wait for a message, in milliseconds. If
     *             <code>-1</code>, don't wait, if <code>0</code> wait
     *             indefinitely, otherwise wait the specified time.
     * @return the received message, or <code>null</code>, if no message is
     *         available
     * @throws JMSException if an error occurs retrieving the message, the
     *                      session is closed, or a message listener is set.
     */
    protected Message retrieveMessage(long wait) throws JMSException {
        if (_messageListener != null) {
            // cannot call this method when a listener is defined
            throw new JMSException("Can't receive when listener defined");
        }

        if (_closed) {
            // cannot call this method when a listener is defined
            throw new JMSException("Can't receive when session closed");
        }

        MessageImpl message =
                (MessageImpl) _session.retrieveMessage(_consumerId, wait);
        if (message != null) {
            _lastMessageDelivered = message.getId();
        }

        return message;
    }

    /**
     * Return the last message asynchronously delivered to the consumer
     *
     * @return the last message delivered
     */
    protected String getLastMessageDelivered() {
        return _lastMessageDelivered;
    }

    /**
     * Returns the destination to receive messages from
     *
     * @return the destination to receive messages from
     */
    protected Destination getDestination() {
        return _destination;
    }

    /**
     * Returns the identity of this consumer
     *
     * @return the identity of this consumer
     */
    protected long getConsumerId() {
        return _consumerId;
    }

    /**
     * Returns the session that created this consumer
     *
     * @return the session that created this consumer
     */
    protected JmsSession getSession() {
        return _session;
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久不卡网国产精品二区| 久久久久久久久久久久久夜| 精品国精品国产| 国产精品嫩草99a| 婷婷激情综合网| 成人丝袜高跟foot| 欧美一区二区福利在线| 亚洲视频一区二区在线观看| 老司机免费视频一区二区三区| 色婷婷国产精品| 中文字幕免费一区| 精品中文字幕一区二区| 欧美久久婷婷综合色| 亚洲免费毛片网站| 成人高清免费在线播放| 久久综合九色综合97_久久久| 亚洲一区二区三区四区中文字幕| www.欧美日韩| 久久精品欧美一区二区三区不卡| 免费成人美女在线观看.| 在线视频中文字幕一区二区| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 成人三级在线视频| 欧美一区二区三区四区高清 | 亚洲美女免费视频| 国产91露脸合集magnet| 日韩免费高清视频| 老鸭窝一区二区久久精品| 911精品产国品一二三产区 | 国产精品国产精品国产专区不蜜| 国产一区在线看| 欧美精品一区在线观看| 狠狠色丁香婷婷综合久久片| 日韩精品中午字幕| 美女脱光内衣内裤视频久久网站| 欧美二区三区的天堂| 亚洲精品国产一区二区精华液 | 日本vs亚洲vs韩国一区三区二区| 欧美精品123区| 免费日韩伦理电影| 日韩一区二区三区在线观看 | 久久新电视剧免费观看| 激情图片小说一区| 国产欧美日韩不卡免费| 成人av在线资源| 亚洲欧美日韩一区二区| 欧美三日本三级三级在线播放| 亚洲一区二区欧美激情| 日韩一区二区在线看片| 国产精品一区二区在线播放| 国产欧美精品在线观看| 91亚洲大成网污www| 亚洲一区二区四区蜜桃| 日韩免费高清av| 国产九九视频一区二区三区| 国产精品久久久久久妇女6080| 色网站国产精品| 婷婷一区二区三区| 国产日韩欧美一区二区三区乱码| av激情亚洲男人天堂| 亚洲女人****多毛耸耸8| 欧美日韩不卡视频| 极品少妇一区二区三区精品视频| 亚洲国产成人自拍| 欧美在线色视频| 国内久久婷婷综合| 亚洲嫩草精品久久| 日韩欧美一级在线播放| 成人黄色在线看| 日产国产高清一区二区三区| 国产日韩欧美综合在线| 欧美日本韩国一区| 国产91丝袜在线播放九色| 亚洲在线免费播放| 国产清纯美女被跳蛋高潮一区二区久久w | 国产成人一级电影| 亚洲综合成人在线视频| www久久久久| 欧美网站一区二区| 91精品欧美一区二区三区综合在| 色综合婷婷久久| 免费久久精品视频| 久久久久亚洲蜜桃| 欧美午夜一区二区三区 | 亚洲欧美电影一区二区| 91精品啪在线观看国产60岁| 成人18视频日本| 秋霞午夜av一区二区三区| 亚洲精品欧美在线| 国产午夜精品一区二区三区视频| 欧美久久免费观看| 91免费版pro下载短视频| 国产自产视频一区二区三区| 亚洲午夜免费福利视频| 中文字幕日本不卡| 久久久蜜桃精品| 日韩欧美一区二区三区在线| 欧美在线不卡视频| 91啪九色porn原创视频在线观看| 国产在线国偷精品免费看| 日韩精品国产欧美| 亚洲一区二区三区四区不卡| 亚洲欧洲精品成人久久奇米网| 久久亚洲影视婷婷| 欧美成人性战久久| 在线播放欧美女士性生活| 日本精品免费观看高清观看| fc2成人免费人成在线观看播放| 国产精一区二区三区| 国产一区二区三区高清播放| 精品写真视频在线观看| 裸体一区二区三区| 免费xxxx性欧美18vr| 五月婷婷综合网| 亚洲va中文字幕| 午夜电影一区二区| 三级久久三级久久| 青青草原综合久久大伊人精品| 亚洲图片自拍偷拍| 亚洲午夜久久久| 日韩高清不卡一区二区三区| 日本视频免费一区| 秋霞午夜鲁丝一区二区老狼| 麻豆国产精品一区二区三区| 久久疯狂做爰流白浆xx| 美美哒免费高清在线观看视频一区二区 | 91视频在线看| 一本大道av伊人久久综合| 欧美中文字幕不卡| 欧美日韩免费电影| 欧美一区二区三区在线观看视频| 9191成人精品久久| 精品噜噜噜噜久久久久久久久试看 | 色综合久久久久综合体桃花网| 色综合久久天天| 欧美日产在线观看| 日韩丝袜情趣美女图片| 久久女同互慰一区二区三区| 国产亚洲综合性久久久影院| 亚洲欧洲另类国产综合| 亚洲小说欧美激情另类| 麻豆精品视频在线观看视频| 国产大陆a不卡| 色欧美乱欧美15图片| 欧美精品aⅴ在线视频| 久久毛片高清国产| 一区二区三区免费网站| 蜜桃视频在线观看一区| 成人免费视频一区| 精品视频在线视频| 久久伊人蜜桃av一区二区| 中文字幕中文字幕中文字幕亚洲无线| 亚洲自拍欧美精品| 激情综合色综合久久| 色综合一个色综合亚洲| 欧美大肚乱孕交hd孕妇| 日韩美女精品在线| 精品一区二区三区免费视频| 91小视频免费看| 日韩欧美一级在线播放| 亚洲免费高清视频在线| 精品一区二区三区久久| 欧美色大人视频| 中国av一区二区三区| 青青草原综合久久大伊人精品| 99精品欧美一区| 精品三级av在线| 亚洲午夜在线观看视频在线| 国产不卡免费视频| 欧美一区二区在线看| 亚洲天堂福利av| 国产精品中文字幕日韩精品 | 久久伊人中文字幕| 亚洲一区二区3| 波多野结衣中文一区| 精品久久久久久无| 亚洲bt欧美bt精品| 99久久国产综合色|国产精品| 久久影院午夜论| 日精品一区二区| 在线日韩av片| 国产精品不卡一区二区三区| 国产成人自拍网| 亚洲精品在线观| 琪琪久久久久日韩精品| 91久久久免费一区二区| 亚洲欧洲精品成人久久奇米网| 久久99国产乱子伦精品免费| 在线播放91灌醉迷j高跟美女 | 日本午夜精品一区二区三区电影 | 亚洲亚洲人成综合网络| 一本色道久久综合亚洲91| 国产精品美女一区二区| 岛国精品在线观看| 久久精品视频在线免费观看| 精品一区二区三区久久久| 精品国产1区二区| 国产综合一区二区| 欧美精品一区二| 国产一区免费电影|