Search in sources :

Example 16 with DestinationUID

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

the class ProducerManagerMonitor method getNumWildcardProducers.

public Integer getNumWildcardProducers(String wildcard) throws MBeanException {
    int numWildcardProducers = Producer.getNumWildcardProducers();
    if (numWildcardProducers <= 0) {
        return (Integer.valueOf(0));
    }
    Iterator producers = Producer.getWildcardProducers();
    if (producers == null) {
        return (Integer.valueOf(0));
    }
    int count = 0;
    while (producers.hasNext()) {
        ProducerUID pid = (ProducerUID) producers.next();
        Producer oneProd = (Producer) Producer.getProducer(pid);
        /*
             * If wildcard param is not null, check for matches If it is null, return total count of wildcards
             */
        if (wildcard != null) {
            DestinationUID id = oneProd.getDestinationUID();
            if (id.getName().equals(wildcard)) {
                count++;
            }
        } else {
            count++;
        }
    }
    return (Integer.valueOf(count));
}
Also used : DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) Producer(com.sun.messaging.jmq.jmsserver.core.Producer) ProducerUID(com.sun.messaging.jmq.jmsserver.core.ProducerUID) Iterator(java.util.Iterator)

Example 17 with DestinationUID

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

the class ConsumerManagerMonitor method getNumWildcardConsumers.

public Integer getNumWildcardConsumers(String wildcard) throws MBeanException {
    int numWildcardConsumers = Consumer.getNumWildcardConsumers();
    if (numWildcardConsumers <= 0) {
        return (Integer.valueOf(0));
    }
    Iterator consumers = Consumer.getWildcardConsumers();
    if (consumers == null) {
        return (Integer.valueOf(0));
    }
    int count = 0;
    while (consumers.hasNext()) {
        ConsumerUID cid = (ConsumerUID) consumers.next();
        Consumer oneCon = Consumer.getConsumer(cid);
        /*
             * If wildcard param is not null, check for matches If it is null, return total count of wildcards
             */
        if (wildcard != null) {
            DestinationUID id = oneCon.getDestinationUID();
            if (id.getName().equals(wildcard)) {
                count++;
            }
        } else {
            count++;
        }
    }
    return (Integer.valueOf(count));
}
Also used : DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) Consumer(com.sun.messaging.jmq.jmsserver.core.Consumer) ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID) Iterator(java.util.Iterator)

Example 18 with DestinationUID

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

the class ProducerUtil method getDestinationNames.

private static String[] getDestinationNames(ProducerUID pid) {
    Producer p = (Producer) Producer.getProducer(pid);
    String[] ret = null;
    if (p == null) {
        return (null);
    }
    ArrayList<String> al = new ArrayList<>();
    Set dests = p.getDestinations();
    Iterator itr = dests.iterator();
    while (itr.hasNext()) {
        DestinationUID duid = (DestinationUID) itr.next();
        al.add(duid.getName());
    }
    if (al.size() > 0) {
        ret = new String[al.size()];
        ret = al.toArray(ret);
    }
    return (ret);
}
Also used : Set(java.util.Set) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) Producer(com.sun.messaging.jmq.jmsserver.core.Producer) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 19 with DestinationUID

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

the class TransactionLogReplayer method replaySentMessage.

private void replaySentMessage(TransactionWorkMessage workMessage, Set dstLoadedSet) throws IOException, BrokerException {
    // Reconstruct the message
    Packet pkt = workMessage.getMessage();
    SysMessageID mid = pkt.getSysMessageID();
    if (Store.getDEBUG()) {
        String msg = getPrefix() + " replaying sent message: " + workMessage + " dest= " + pkt.getDestination();
        logger.log(Logger.INFO, msg);
    }
    // Make sure destination exists; auto-create if necessary
    // TODO
    // recreating destinations may cause a bug if a destination had been
    // deleted by a command after the message was logged.
    // It will now reappear - (as an auto destination?)
    String dname = pkt.getDestination();
    int dtype = (pkt.getIsQueue() ? DestType.DEST_TYPE_QUEUE : DestType.DEST_TYPE_TOPIC);
    List[] dss = DestinationList.findMatchingIDs(msgStore.parent, DestinationUID.getUID(dname, dtype));
    List dlist = dss[0];
    DestinationUID did = null;
    Iterator itr = dlist.iterator();
    while (itr.hasNext()) {
        did = (DestinationUID) itr.next();
        Destination[] ds = DestinationList.getDestination(msgStore.parent, did, dtype, true, true);
        Destination dst = ds[0];
        did = dst.getDestinationUID();
        // Load all msgs in order to verify if any msgs are missing
        if (!dstLoadedSet.contains(dst)) {
            dst.load();
            // Keep track of what has been loaded
            dstLoadedSet.add(dst);
        }
        // Check to see if the msg is in the store
        boolean exists = msgStore.containsMessage(did, mid);
        if (exists) {
            if (Store.getDEBUG()) {
                String msg = getPrefix() + " stored message exists " + mid;
                logger.log(Logger.INFO, msg);
            }
            // check if stored interests are the same as logged interests
            HashMap storedInterests = msgStore.getInterestStates(did, mid);
            boolean matched = compareStoredConsumers(mid, workMessage.getStoredInterests(), storedInterests);
            if (!matched) {
                logger.log(Logger.FORCE, BrokerResources.I_REPLACE_MSG_TXNLOG, mid);
                dst.removeMessage(mid, RemoveReason.REMOVED_OTHER);
                if (msgStore.containsMessage(did, mid)) {
                    msgStore.removeMessage(did, mid, false);
                }
                rerouteMessage(pkt, mid, dst);
            }
        } else {
            if (Store.getDEBUG()) {
                String msg = getPrefix() + " stored message does not exist " + mid;
                logger.log(Logger.INFO, msg);
            }
            rerouteMessage(pkt, mid, dst);
        }
    }
// while
}
Also used : Packet(com.sun.messaging.jmq.io.Packet) Destination(com.sun.messaging.jmq.jmsserver.core.Destination) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) HashMap(java.util.HashMap) Iterator(java.util.Iterator) SysMessageID(com.sun.messaging.jmq.io.SysMessageID) DestinationList(com.sun.messaging.jmq.jmsserver.core.DestinationList) List(java.util.List)

Example 20 with DestinationUID

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

the class TransactionLogReplayer method replayMessageRemoval.

public void replayMessageRemoval(MsgRemovalEvent event, Set dstLoadedSet) throws IOException, BrokerException {
    DestinationUID did = event.destUID;
    SysMessageID mid = event.sysMessageID;
    // Make sure dst exists; autocreate if possible
    Destination[] ds = Globals.getDestinationList().getDestination(msgStore.parent, did.getName(), did.isQueue() ? DestType.DEST_TYPE_QUEUE : DestType.DEST_TYPE_TOPIC, true, true);
    Destination dst = ds[0];
    // Load all msgs inorder to update consumer states
    if (!dstLoadedSet.contains(dst)) {
        dst.load();
        // Keep track of what has been loaded
        dstLoadedSet.add(dst);
    }
    logger.log(Logger.FORCE, Globals.getBrokerResources().getKString(BrokerResources.I_RM_MSG_ON_REPLAY_MSG_REMOVAL, mid, dst));
    dst.removeMessage(mid, RemoveReason.REMOVED_OTHER);
    if (msgStore.containsMessage(did, mid)) {
        msgStore.removeMessage(did, mid, false);
    }
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) SysMessageID(com.sun.messaging.jmq.io.SysMessageID)

Aggregations

DestinationUID (com.sun.messaging.jmq.jmsserver.core.DestinationUID)61 Destination (com.sun.messaging.jmq.jmsserver.core.Destination)25 ConsumerUID (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)20 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)20 Iterator (java.util.Iterator)18 SysMessageID (com.sun.messaging.jmq.io.SysMessageID)16 Consumer (com.sun.messaging.jmq.jmsserver.core.Consumer)16 PacketReference (com.sun.messaging.jmq.jmsserver.core.PacketReference)10 Producer (com.sun.messaging.jmq.jmsserver.core.Producer)9 ArrayList (java.util.ArrayList)9 Packet (com.sun.messaging.jmq.io.Packet)8 SelectorFormatException (com.sun.messaging.jmq.util.selector.SelectorFormatException)8 IOException (java.io.IOException)8 ProducerUID (com.sun.messaging.jmq.jmsserver.core.ProducerUID)6 PartitionedStore (com.sun.messaging.jmq.jmsserver.persist.api.PartitionedStore)6 HashMap (java.util.HashMap)6 BrokerAddress (com.sun.messaging.jmq.jmsserver.core.BrokerAddress)5 DestinationList (com.sun.messaging.jmq.jmsserver.core.DestinationList)5 Session (com.sun.messaging.jmq.jmsserver.core.Session)5 SessionUID (com.sun.messaging.jmq.jmsserver.core.SessionUID)5