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

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

?? sentmessagecache.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 2002-2004 (C) Exoffice Technologies Inc. All Rights Reserved.
 *
 * $Id: SentMessageCache.java,v 1.2 2005/03/18 04:07:02 tanderson Exp $
 */
package org.exolab.jms.server;

import java.sql.Connection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import javax.jms.Session;
import javax.jms.JMSException;

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

import org.exolab.jms.messagemgr.MessageHandle;
import org.exolab.jms.messagemgr.DestinationManager;
import org.exolab.jms.messagemgr.DestinationCache;
import org.exolab.jms.persistence.DatabaseService;
import org.exolab.jms.persistence.PersistenceException;
import org.exolab.jms.persistence.SQLHelper;


/**
 * Helper class to cache all sent messages and unacked messages for a
 * session. It also does some other processing like marking the message
 * as sent to minimize the number of transactions.
 * <p>
 * Messages will only be added to the cache, if the session is transacted
 * or the ack mode for the session is set to CLIENT_ACKNOWLEDGE
 *
 * @version     $Revision: 1.2 $ $Date: 2005/03/18 04:07:02 $
 * @author      <a href="mailto:jima@exoffice.com">Jim Alateras</a>
 * @author      <a href="mailto:tma@netspace.net.au">Tim Anderson</a>
 * @see         JmsServerSession
 */
class SentMessageCache {

    /**
     * The session which owns this instance
     */
    private JmsServerSession _session;

    /**
     * Holds a list of unacked messages in the order they were sent
     */
    private List _unackedMessages = Collections.synchronizedList(
        new LinkedList());

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


    /**
     * Construct a new <code>SentMessageCache</code>
     *
     * @param session the session which manages this
     */
    public SentMessageCache(JmsServerSession session) {
        _session = session;
    }

    /**
     * Mark the message as delivered and do one of the following.
     * <p>
     * If the session is transacted or the session ack mode is set to
     * CLIENT_ACKNOWLEDGE then add this message to the list of unacked
     * messages.
     * <p>
     * If the session ack mode is anything else then destroy the handle.
     * <p>
     * If the handle is a reference to a persistent message then conduct
     * this work in the context of a transaction.
     *
     * @param handle the message handle that should be acked
     */
    public void process(MessageHandle handle) throws JMSException {
        if (handle.isPersistent()) {
            Connection connection = null;
            try {
                connection = DatabaseService.getConnection();

                handle.setDelivered(true);
                if (_session.isTransacted() ||
                    _session.getAckMode() == Session.CLIENT_ACKNOWLEDGE) {
                    _unackedMessages.add(handle);
                    handle.update(connection);
                } else {
                    // in all other ack modes, simply destroy the handle
                    handle.destroy(connection);
                }
                connection.commit();
            } catch (PersistenceException exception) {
                SQLHelper.rollback(connection);
                _log.error("Error in SentMessageCache.process", exception);
            } catch (Exception exception) {
                _log.error("Error in SentMessageCache.process", exception);
            } finally {
                SQLHelper.close(connection);
            }
        } else {
            handle.setDelivered(true);
            if (_session.isTransacted() ||
                _session.getAckMode() == Session.CLIENT_ACKNOWLEDGE) {
                _unackedMessages.add(handle);
            } else {
                handle.destroy();
            }
        }
    }

    /**
     * Acknowledge the specified messages in the cache and all previously
     * sent messages.
     *
     * @param messageId the id of the message to ack
     * @param consumerId the consumer id that sent the ack.
     */
    public void acknowledgeMessage(String messageId, long consumerId) {
        // first check that the message exists in the list of unacked
        // messages
        boolean exists = false;
        Iterator iterator = _unackedMessages.iterator();
        while (iterator.hasNext()) {
            MessageHandle handle = (MessageHandle) iterator.next();
            if (handle.getConsumerId() == consumerId
                    && handle.getMessageId().equals(messageId)) {
                exists = true;
                break;
            }
        }

        if (exists) {
            boolean intransaction = false;
            Connection connection = null;

            try {
                // start from the top of the cache and remove each
                // message and then call destroy on it.
                // We should do this in one transaction.
                while (!_unackedMessages.isEmpty()) {
                    MessageHandle handle =
                        (MessageHandle) _unackedMessages.remove(0);
                    if (handle.isPersistent()) {
                        if (!intransaction) {
                            connection = DatabaseService.getConnection();

                            // begin the transaction
                            intransaction = true;
                        }
                        handle.destroy(connection);
                    } else {
                        handle.destroy();
                    }

                    // if the handle is equal to the source handle then
                    // break the loop
                    if (handle.getConsumerId() == consumerId
                            && handle.getMessageId().equals(messageId)) {
                        if (intransaction) {
                            connection.commit();
                            intransaction = false;
                        }
                        break;
                    }
                }
            } catch (PersistenceException exception) {
                SQLHelper.rollback(connection);
                _log.error("Error in SentMessageCache.acknowledgeMessage",
                           exception);
            } catch (Exception exception) {
                _log.error("Error in SentMessageCache.acknowledgeMessage",
                           exception);
            } finally {
                SQLHelper.close(connection);
            }
        }
    }

    /**
     * Acknowledge all the messages in the cache
     */
    public void acknowledgeAllMessages() {
        boolean intransaction = false;
        Connection connection = null;

        try {
            // start from the top of the cache and remove each
            // message and then call destroy on it.
            // We should do this in one transaction.
            while (!_unackedMessages.isEmpty()) {
                MessageHandle handle =
                    (MessageHandle) _unackedMessages.remove(0);
                if (handle.isPersistent()) {
                    if (!intransaction) {
                        connection = DatabaseService.getConnection();
                        intransaction = true;
                    }
                    handle.destroy(connection);
                } else {
                    handle.destroy();
                }
            }

            if (intransaction) {
                connection.commit();
                intransaction = false;
            }
        } catch (PersistenceException exception) {
            SQLHelper.rollback(connection);
            _log.error("Error in SentMessageCache.acknowledgeMessage",
                       exception);
        } catch (Exception exception) {
            _log.error("Error in SentMessageCache.acknowledgeMessage",
                       exception);
        } finally {
            SQLHelper.close(connection);
        }
    }

    /**
     * Clear the cache by removing each entry and doing one of the
     * following.
     * <p>
     * If the entry is for a queue destination then return it to
     * the appropriate destination cache. If the cache does not
     * exist, because it may have been garbage collected then we
     * need to recreated.
     * <p>
     * If the entry is for a topic destination and check if the
     * corresponding endpoint is still active. If it is then return it
     * to the endpoint, otherwise do nothing.
     */
    public void clear() throws JMSException {
        // copy the array of unacked messages
        Object[] unacked = _unackedMessages.toArray();
        _unackedMessages.clear();

        int count = unacked.length;
        for (int index = 0; index < count; index++) {
            MessageHandle handle = (MessageHandle) unacked[index];
            DestinationCache cache = 
                    DestinationManager.instance().getDestinationCache(handle.getDestination());
            cache.returnMessageHandle(handle);
        }
    }

    /**
     * Check whether the specified handle is in the list of unacked
     * messages
     *
     * @param handle the handle to check
     * @return <code>true</code> if it is in the list of unacked messages
     */
    public boolean handleInCache(MessageHandle handle) {
        return _unackedMessages.contains(handle);
    }

    /**
     * Remove the specified handle from the cache
     *
     * @param handle the handle to remove
     */
    public void removeHandle(MessageHandle handle) {
        _unackedMessages.remove(handle);
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成精国产精品女| 又紧又大又爽精品一区二区| 色94色欧美sute亚洲线路二| 国产精品一区一区| 国产一区二区91| 国内久久婷婷综合| 国产精品一区2区| 国模冰冰炮一区二区| 国产综合色在线| 国产福利不卡视频| 国产精品综合二区| 成人自拍视频在线| 成人国产一区二区三区精品| www.欧美.com| 91免费看片在线观看| 色综合久久久久综合体| 在线免费一区三区| 欧美精品xxxxbbbb| 日韩免费在线观看| 久久影院视频免费| 欧美激情一区二区三区| 国产精品激情偷乱一区二区∴| 国产精品日韩精品欧美在线| 国产精品成人网| 亚洲一区二区三区三| 日日夜夜一区二区| 精品亚洲国内自在自线福利| 大陆成人av片| 欧美在线观看视频一区二区| 日韩亚洲欧美在线观看| 国产精品久久久久四虎| 一区二区在线观看视频| 日韩极品在线观看| 国产传媒久久文化传媒| 色嗨嗨av一区二区三区| 日韩免费电影一区| 中文字幕一区二区5566日韩| 日韩有码一区二区三区| 国产美女久久久久| 欧美最猛性xxxxx直播| 欧美一区二区三级| 亚洲视频香蕉人妖| 蜜桃一区二区三区四区| 91丨九色porny丨蝌蚪| 欧美精品欧美精品系列| 国产日韩亚洲欧美综合| 日韩经典一区二区| 99久久综合国产精品| 欧美一级夜夜爽| 1000精品久久久久久久久| 蜜桃av噜噜一区二区三区小说| 成人av网站大全| 日韩欧美一区二区不卡| 亚洲精品老司机| 国产福利不卡视频| 欧美xxxx在线观看| 午夜视频在线观看一区| zzijzzij亚洲日本少妇熟睡| 精品三级av在线| 五月综合激情网| 北条麻妃国产九九精品视频| 久久女同互慰一区二区三区| 日韩精品一卡二卡三卡四卡无卡| 色婷婷亚洲精品| 亚洲欧洲精品成人久久奇米网| 精品无码三级在线观看视频| 777欧美精品| 亚洲成人午夜影院| 一本到三区不卡视频| 国产精品久久看| 大白屁股一区二区视频| 久久夜色精品一区| 久久精品国产精品亚洲红杏| 欧美一区二区三区电影| 视频在线观看一区二区三区| 在线欧美一区二区| 亚洲精品国产a| 99r国产精品| 亚洲欧洲三级电影| 99在线精品一区二区三区| 中文一区一区三区高中清不卡| 国产精品一区不卡| 国产亚洲欧美在线| 国产99久久精品| 日本一区二区综合亚洲| 成人网在线播放| 国产精品久久久久一区| www.欧美日韩| 亚洲综合网站在线观看| 欧美性猛片aaaaaaa做受| 图片区小说区区亚洲影院| 67194成人在线观看| 蜜臀av一区二区在线免费观看| 欧美成人精品高清在线播放| 国产精品一区在线| 国产精品短视频| 在线观看91精品国产入口| 一区二区三区精品| 欧美一区二区三区免费视频| 黑人精品欧美一区二区蜜桃| 国产精品视频yy9299一区| 色综合久久中文综合久久97| 视频在线观看国产精品| 久久久久久久久免费| 9i在线看片成人免费| 五月婷婷激情综合| 久久综合狠狠综合久久综合88| 成人午夜看片网址| 婷婷综合另类小说色区| 亚洲精品一区在线观看| 91视频一区二区| 日本欧洲一区二区| 国产精品高潮呻吟久久| 欧美日韩一本到| 国产盗摄精品一区二区三区在线| 亚洲蜜臀av乱码久久精品蜜桃| 欧美精品乱码久久久久久 | 久久久久久久综合狠狠综合| 成人动漫一区二区在线| 日本中文字幕一区二区视频 | 中文字幕久久午夜不卡| 色噜噜久久综合| 韩国成人福利片在线播放| 成人免费一区二区三区在线观看| 69成人精品免费视频| 99久久婷婷国产综合精品电影| 香蕉久久夜色精品国产使用方法| 国产日韩欧美高清| 欧美日韩激情一区二区| 成人av电影免费在线播放| 九九**精品视频免费播放| 亚洲三级免费观看| 国产校园另类小说区| 欧美久久久影院| 色偷偷一区二区三区| 国产电影一区二区三区| 秋霞午夜av一区二区三区| 亚洲女同ⅹxx女同tv| 欧美激情在线一区二区| 精品久久久久香蕉网| 欧美日韩电影在线| 91网站最新地址| www.爱久久.com| 国产精品一区一区三区| 精品一区二区三区免费视频| 亚洲成人久久影院| 亚洲精品一二三区| 国产精品青草久久| 国产亚洲美州欧州综合国| 日韩欧美国产精品一区| 91精品婷婷国产综合久久性色 | 日韩国产欧美一区二区三区| 亚洲美腿欧美偷拍| 亚洲欧美国产高清| 亚洲精品亚洲人成人网在线播放| 国产精品亲子乱子伦xxxx裸| 国产亚洲制服色| 久久久久国产一区二区三区四区| 日韩女优视频免费观看| 精品久久一二三区| 日韩精品一区二区三区在线播放 | 激情深爱一区二区| 美国精品在线观看| 激情欧美一区二区三区在线观看| 免费视频一区二区| 精品一区二区三区久久| 精品一二三四在线| 丰满亚洲少妇av| 成人的网站免费观看| 9色porny自拍视频一区二区| 色噜噜狠狠一区二区三区果冻| 色婷婷综合在线| 欧美美女激情18p| 91精品国产综合久久国产大片| 日韩精品一区在线| 国产清纯在线一区二区www| 1000部国产精品成人观看| 亚洲免费观看高清完整版在线观看 | 久久aⅴ国产欧美74aaa| 国产麻豆精品在线观看| 成人动漫中文字幕| 精品视频999| 欧美mv和日韩mv国产网站| 亚洲国产高清aⅴ视频| 亚洲午夜三级在线| 狠狠色丁香久久婷婷综合_中| 成人性色生活片| 欧洲中文字幕精品| 精品国产伦理网| 最新欧美精品一区二区三区| 亚洲国产精品影院| 国产乱淫av一区二区三区 | 亚洲免费在线播放| 久久精品国产精品亚洲综合| 99久久精品国产导航| 91精品国产91久久综合桃花| 国产精品国产精品国产专区不蜜| 性做久久久久久久免费看| 成人免费视频一区| 91精品黄色片免费大全|