Search in sources :

Example 1 with SelectorFilter

use of com.sun.messaging.jmq.jmsserver.core.SelectorFilter in project openmq by eclipse-ee4j.

the class QBrowseHandler method getQBrowseList.

public ArrayList getQBrowseList(Destination d, String selectorstr) throws BrokerException, SelectorFormatException {
    Collection msgs = null;
    if (selectorstr == null) {
        msgs = d.getAll((Filter) null).values();
    } else {
        SelectorFilter f = new SelectorFilter(selectorstr);
        Map m = d.getAll(f);
        msgs = m.values();
    }
    // sort the messages
    ArrayList sorted = new ArrayList(msgs);
    Collections.sort(sorted, new RefCompare());
    TransactionList[] tls = DL.getTransactionList(d.getPartitionedStore());
    TransactionList tlist = tls[0];
    // remove any expired messages or messages in open txn
    Iterator itr = sorted.iterator();
    while (itr.hasNext()) {
        PacketReference p = (PacketReference) itr.next();
        if (p.isExpired()) {
            itr.remove();
        }
        if (!p.isDeliveryDue()) {
            itr.remove();
        }
        if (p.getTransactionID() != null) {
            // look up txn
            TransactionState ts = tlist.retrieveState(p.getTransactionID());
            if (ts != null && ts.getState() != TransactionState.COMMITTED) {
                // open txn, remove
                itr.remove();
            }
        }
        // check in takeover processing
        if (p.checkLock(false) == null) {
            itr.remove();
        }
    }
    ArrayList returnmsgs = new ArrayList();
    itr = sorted.iterator();
    while (itr.hasNext()) {
        PacketReference p = (PacketReference) itr.next();
        if (p == null) {
            continue;
        }
        returnmsgs.add(p.getSysMessageID());
    }
    return returnmsgs;
}
Also used : TransactionState(com.sun.messaging.jmq.jmsserver.data.TransactionState) SelectorFilter(com.sun.messaging.jmq.jmsserver.core.SelectorFilter) PacketReference(com.sun.messaging.jmq.jmsserver.core.PacketReference) TransactionList(com.sun.messaging.jmq.jmsserver.data.TransactionList)

Aggregations

PacketReference (com.sun.messaging.jmq.jmsserver.core.PacketReference)1 SelectorFilter (com.sun.messaging.jmq.jmsserver.core.SelectorFilter)1 TransactionList (com.sun.messaging.jmq.jmsserver.data.TransactionList)1 TransactionState (com.sun.messaging.jmq.jmsserver.data.TransactionState)1