Package com.sun.messaging.jmq.jmsserver.core

Examples of com.sun.messaging.jmq.jmsserver.core.ConsumerUID


     */
    void removeInterest(Consumer interest)
  throws IOException, BrokerException {

  Object oldinterest = null;
        ConsumerUID id = interest.getConsumerUID();

        try {
            oldinterest = interestMap.remove(id);
            if (oldinterest == null) {
                logger.log(Logger.ERROR,
View Full Code Here


            l = new ArrayList(consumers.keySet());
        }
        ht.put("consumersCount", l.size());
        itr = l.iterator();
        while (itr.hasNext()) {
            ConsumerUID cuid = (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)itr.next();
            Consumer c = (Consumer)consumers.get(cuid);
            if (c instanceof Subscription) {
                ht.put("[consumers]"+cuid.toString(), "Subscription: "+c);
            } else {
                ht.put("[consumers]"+cuid.toString(), c.toString());
            }
        }

        synchronized(activeConsumers) {
            l = new ArrayList(activeConsumers);
        }
        ht.put("activeConsumersCount", l.size());
        Vector v = new Vector();
        itr = l.iterator();
        while (itr.hasNext()) {
            Consumer c = (Consumer)itr.next();
            if (c instanceof Subscription) {
                v.add("Subscription: "+c);
            } else {
                v.add(c.toString());
            }
        }
        ht.put("activeConsumers", v);

        synchronized(pendingConsumerUIDs) {
            l = new ArrayList(pendingConsumerUIDs.keySet());
        }
        ht.put("pendingConsumerUIDsCount", l.size());
        itr = l.iterator();
        while (itr.hasNext()) {
            ConsumerUID cuid = (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)itr.next();
            synchronized(deliveredMessages) {

            Set pending = (Set)pendingConsumerUIDs.get(cuid);
            if (pending == null) {
                ht.put("[pendingConsumerUIDs]"+cuid.toString(), "null");
            } else {
                v = new Vector(pending);
                if (v.size() == 0) {
                    ht.put("[pendingConsumerUIDs]"+cuid.toString(), "none");
                } else {
                    ht.put("[pendingConsumerUIDs]"+cuid.toString(), v);
                }
            }

            }
        }

        synchronized(cleanupList) {
            l = new ArrayList(cleanupList.keySet());
        }
        ht.put("cleanupListCount", l.size());
        v = new Vector();
        itr = l.iterator();
        while (itr.hasNext()) {
            ConsumerUID cuid = (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)itr.next();
            v.add(cuid.toString());
        }
        ht.put("cleanupList", v);

        synchronized(listeners) {
            l = new ArrayList(listeners.keySet());
        }
        ht.put("listenersCount", l.size());
        v = new Vector();
        itr = l.iterator();
        while (itr.hasNext()) {
            ConsumerUID cuid = (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)itr.next();
            v.add(cuid.toString());
        }
        ht.put("listeners", v);

        return ht;
    }
View Full Code Here

        for (int i = 0; i < ackCount; i++) {
            String name = dis.readUTF(); // Destination ID
            DestinationUID did = new DestinationUID(name);
            SysMessageID mid = new SysMessageID();
            mid.readID(dis); // SysMessageID
            ConsumerUID iid = new ConsumerUID(dis.readLong()); // ConsumerUID

            // Make sure dst exists; autocreate if possible
            Destination dst = Destination.getDestination(
                did.getName(),
                did.isQueue() ? DestType.DEST_TYPE_QUEUE
                : DestType.DEST_TYPE_TOPIC, true, true);

            // Load all msgs inorder to update consumer states
            if (!dstLoadedSet.contains(dst)) {
                dst.load();
                dstLoadedSet.add(dst); // Keep track of what has been loaded
            }

            if (msgStore.containsMessage(did, mid)) {
                logger.log(logger.FORCE,
                    BrokerResources.I_UPDATE_INT_STATE_TXNLOG, iid, mid);
                // For Queue, ensure the stored ConsumerUID is 0 otherwise
                // use try using the correct value; see bug 6516160
                if (dst.isQueue() && iid.longValue() != 0) {
                    msgStore.updateInterestState(did, mid, PacketReference.getQueueUID(),
                        Store.INTEREST_STATE_ACKNOWLEDGED, false);
                } else {
                    msgStore.updateInterestState(did, mid, iid,
                        Store.INTEREST_STATE_ACKNOWLEDGED, false);
View Full Code Here

        HashMap ignoreUnroutableProp = new HashMap();
        ignoreUnroutableProp.put(ClusterBroadcast.MSG_REMOTE_REJECTED, "true");

        Iterator itr = consumers.iterator();
        while (itr.hasNext()) {
            ConsumerUID uid = (ConsumerUID)itr.next();
            Consumer interest = Consumer.getConsumer(uid);

            if (interest != null && interest.isValid()) {
                // we need the interest for updating the ref
                targetVector.add(interest);
                ConsumerUID suid = interest.getStoredConsumerUID();
                if ((suid == null || suid.equals(uid)) &&
                    interest.getSubscription() == null) {
                    hasflowcontrol = false;
                }
            } else {
                ignoreVector.add(uid);
            }
        }

        boolean exists = false;
        PacketReference ref = Destination.get(p.getSysMessageID());
        if (ref != null) {
            BrokerAddress addr = ref.getAddress();
            if (addr == null || !addr.equals(sender)) {
                if (DEBUG) {
                logger.log(Logger.INFO,
                "Remote message "+ref.getSysMessageID()+ " home broker "+addr+" changed to "+sender);
                }
                Destination.remoteCheckMessageHomeChange(ref, sender);
            }
        }
        ref = Destination.get(p.getSysMessageID());
        if (ref != null) {
            exists = true;
            ref.setBrokerAddress(sender);
            if (p.getRedelivered()) ref.overrideRedeliver();
        } else {
            ref = PacketReference.createReference(p, null);
            ref.setBrokerAddress(sender);
        }
        // XXX - note, we send a reply for all message delivered
        //       acks, that is incorrect
        //       really, we should have a sendMsgDeliveredAck per
        //       consumer
        if (sendMsgDeliveredAck) {
            for (int i=0; i < targetVector.size(); i ++) {
                Consumer c = (Consumer)targetVector.get(i);
                //ref.addMessageDeliveredAck(c.getStoredConsumerUID());
                ref.addMessageDeliveredAck(c.getConsumerUID());
            }
        }
        List dsts = null;
        ArrayList cleanupDests = new ArrayList();
        try {
            if (ref == null)  {
                return;
            }
            if (ref.getDestinationUID().isWildcard()) {
                dsts = Destination.findMatchingIDs(ref.getDestinationUID());
            } else {
                // ok, autocreate the destination if necessary
                Destination d = Destination.getDestination(
                    ref.getDestinationUID().getName(),
                    ref.getDestinationUID().isQueue() ? DestType.DEST_TYPE_QUEUE
                       : DestType.DEST_TYPE_TOPIC, true, true);
                if (d != null) {
                    dsts = new ArrayList();
                    dsts.add(d.getDestinationUID());
                }
            }
            if (dsts == null || dsts.isEmpty()) {
               ignoreVector.addAll(targetVector);
               targetVector.clear();
            } else {
                if (!exists && !targetVector.isEmpty()) {
                    ref.setNeverStore(true);
                    // OK .. we dont need to route .. its already happened
                    ref.store(targetVector);
                    boolean enforcelimit = false;
                    itr = dsts.iterator();
                    while (itr.hasNext()) {
                        DestinationUID did = (DestinationUID)itr.next();
                        Destination d = Destination.getDestination(did);
                        if (!hasflowcontrol) {
                            enforcelimit = true;
                        } else {
                            String k = ENFORCE_REMOTE_DEST_LIMIT_PROP+did.getLongString();
                            if (Globals.getConfig().getProperty(k) == null) {
                                enforcelimit = ENFORCE_REMOTE_DEST_LIMIT;
                            } else {
                                enforcelimit = Globals.getConfig().getBooleanProperty(k);
                            }
                        }
                        if (DEBUG) {
                            logger.log(logger.INFO, "Route remote message "+ref+ " sent from "+sender+
                                " to destination(s) "+did+" for consumer(s) "+targetVector+" hasflowcontrol="+
                                hasflowcontrol+", enforcelimit="+enforcelimit);
                        }
                        if ((Destination.CHECK_MSGS_RATE_FOR_ALL ||
                             !ref.getDestinationUID().isQueue()) && !ROUTE_REJECTED_REMOTE_MSG) {
                            Consumer cs = null;
                            Subscription sub = null;
                            Iterator csitr = targetVector.iterator();
                            while (csitr.hasNext()) {
                                cs = (Consumer)csitr.next();
                                sub = cs.getSubscription();
                                if (Destination.CHECK_MSGS_RATE_FOR_ALL ||
                                    (CHECK_MSGRATE_ON_ARRIVAL &&
                                     sub != null && sub.getShared() && !sub.isDurable())) {
                                    int ret = cs.checkIfMsgsInRateGTOutRate(d);
                                    if (ret == 0) {
                                        ignoreVector.addAll(targetVector);
                                        targetVector.clear();
                                        ignoreProps = ignoreUnroutableProp;
                                        break;
                                    }
                                }
                            }
                            if (targetVector.isEmpty()) {
                                break;
                            }
                        }
                        if (!d.queueMessage(ref, false, enforcelimit)) { // add to message count
                            ignoreVector.addAll(targetVector);
                            if (!ROUTE_REJECTED_REMOTE_MSG) {
                                targetVector.clear();
                            }
                            break;
                        } else {
                            cleanupDests.add(d);
                        }
                    }
                } else if (exists) {
                    ref.add(targetVector);
                }
            }
        } catch (IOException ex) {
            logger.logStack(logger.INFO,"Internal Exception ", ex);
            ignoreVector.addAll(targetVector);
            if (!ROUTE_REJECTED_REMOTE_MSG) {
                targetVector.clear();
                ignoreProps = ignoreUnroutableProp;
            }
        } catch (BrokerException ex) {
            // unable to store
            ignoreVector.addAll(targetVector);
            if (!ROUTE_REJECTED_REMOTE_MSG) {
                targetVector.clear();
                ignoreProps = ignoreUnroutableProp;
            }
        }

        if (targetVector.isEmpty()) {
            Destination d = null;
            itr = cleanupDests.iterator();
            while (itr.hasNext()) {
                try {
                    d = (Destination)itr.next();
                    d.removeMessage(ref.getSysMessageID(), null);
                } catch (Throwable e) {
                    Object[] args = { ref.getSysMessageID(),
                                      (sender == null ? "":sender),
                                      d, targetVector.toString(), e.toString() };
                    String emsg = Globals.getBrokerResources().getKString(
                                  BrokerResources.W_UNABLE_CLEANUP_REMOTE_MSG_ON_ROUTE, args);
                    if (DEBUG) {
                        logger.logStack(Logger.WARNING,  emsg, e);
                    } else {
                        logger.log(Logger.WARNING, emsg);
                    }
                }
            }
            cleanupDests.clear();
       }

        // Now deliver the message...
        String debugString = "\n";

        int i;
        for (i = 0; i < targetVector.size(); i++) {
            Consumer interest = (Consumer)targetVector.get(i);

            if (!interest.routeMessage(ref, false)) {
                // it disappeard on us, take care of it
               try {
                    if (ref.acknowledged(interest.getConsumerUID(),
                          interest.getStoredConsumerUID(), true, false)) {
                        if (dsts == null) continue;
                        itr = dsts.iterator();
                        while (itr.hasNext()) {
                            DestinationUID did = (DestinationUID)itr.next();
                            Destination d=Destination.getDestination(did);
                            d.removeRemoteMessage(ref.getSysMessageID(),
                                          RemoveReason.ACKNOWLEDGED, ref);
                        }
                    }
                } catch (Exception ex) {
                    logger.log(logger.INFO,"Internal error processing ack",
                           ex);
                }
            } else {
                ref.addRemoteConsumerUID(interest.getConsumerUID(),
                        interest.getConsumerUID().getConnectionUID());
            }



            if (DEBUG) {
                debugString = debugString +
                    "\t" + interest.getConsumerUID() + "\n";
            }
        }

        if (DEBUG) {
            logger.log(logger.DEBUGHIGH,
                "MessageBus: Delivering message to : {0}",
                debugString);
        }

        debugString = "\n";
        // Finally, send  ClusterGlobals.MB_MSG_IGNORED acks if any...
        Object o = null;
        ConsumerUID cuid = null;
        Consumer interest = null;
        for (i = 0; i < ignoreVector.size(); i++) {
            try {
                o = ignoreVector.get(i);
                if (o instanceof Consumer) {
View Full Code Here

     *      in the store already
     */
    void storeInterest(Consumer interest, boolean sync)
  throws IOException, BrokerException {

  ConsumerUID id = interest.getConsumerUID();

        try {
            Object oldValue = interestMap.putIfAbsent(id, interest);
            if (oldValue != null) {
                logger.log(logger.ERROR, br.E_INTEREST_EXISTS_IN_STORE, id,
View Full Code Here

     */
    void removeInterest(Consumer interest, boolean sync)
  throws IOException, BrokerException {

  Object oldinterest = null;
        ConsumerUID id = interest.getConsumerUID();

        try {
            oldinterest = interestMap.remove(id);

            if (oldinterest == null) {
View Full Code Here

        return clientID;
    }


    private ConsumerMessagePair getAck(Object obj) {
        ConsumerUID cuid = null;
        if (obj instanceof ConsumerUID) {
            cuid = (ConsumerUID)obj;
        } else if (obj instanceof Consumer) {
            cuid = ((Consumer)obj).getConsumerUID();
        } else {
View Full Code Here

    List<ConsumerUID> storedConsumers = null;
    Iterator itr = consumers.iterator();

    while (itr.hasNext()) {
      Object o = itr.next();
      ConsumerUID cuid = null;
      if (o instanceof Consumer) {
        cuid = ((Consumer) o).getStoredConsumerUID();
      } else {
        cuid = (ConsumerUID) o;
      }

      if (cuid.shouldStore()) {
        if (storedConsumers == null) {
          storedConsumers = new ArrayList<ConsumerUID>();
        }
        storedConsumers.add(cuid);
      }
View Full Code Here

     */
    public void add(Collection uids) {
        Iterator itr = uids.iterator();
        while (itr.hasNext()) {
           Object o = itr.next();
           ConsumerUID cuid = null, uid = null;
           Session ss = null;
           boolean fixcnt = false;

           if (o instanceof ConsumerUID) {
               cuid = (ConsumerUID)o;
View Full Code Here

            interestCnt +=uids.length;
        }
         

        for (int i=0; i < uids.length; i ++) {
           ConsumerUID cuid = uids[i];

           assert uids[i] != null;

           assert states[i] >= Store.INTEREST_STATE_ROUTED &&
                  states[i] <= Store.INTEREST_STATE_ACKNOWLEDGED;
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.jmsserver.core.ConsumerUID

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.