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

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


     * @exception com.sun.messaging.jmq.jmsserver.util.BrokerException if the destination is not found in the store
     */
    void removeDestination(Destination destination)
  throws BrokerException {

  DestinationUID did = destination.getDestinationUID();

        try {
            Object oldValue = dstMap.remove(did);
            if (oldValue == null) {
                logger.log(Logger.ERROR,
View Full Code Here


        if (clearMessages) {
            Iterator itr = dstMap.values().iterator();
            while (itr.hasNext()) {
                Destination dst = (Destination)itr.next();
                DestinationUID did = dst.getDestinationUID();
                parent.getMsgStore().releaseMessageDir(did);
            }
        }
        dstMap.clear();
    }
View Full Code Here

            pendingConsumerUIDs.put(cuid, null);
            listeners.put(cuid, c.addEventListener(this,
                 EventType.BUSY_STATE_CHANGED, null));
        }

        DestinationUID duid = c.getDestinationUID();

        int type = (duid.isQueue() ? DestType.DEST_TYPE_QUEUE :
                     DestType.DEST_TYPE_TOPIC);

        Destination d= null;

        try {
            // ok handle adding a reference count
            // we'll try at most 2 times to get a
            // destination

            if (duid.isWildcard()) {
                d = null;

            } else {
                for (int i=0; i < 2 && d == null ; i ++) {
                    d = Destination.getDestination(duid.getName(),
                      type, true, true);
   
                    try {
                        // increment the reference count
                        // this make sure that the destination
                        // is not removed by autocreate prematurely   
                        if (d != null) {
                            d.incrementRefCount();
   
                            break; // well we should break anyway, but
                                   // this makes it explicit
                        }
   
                    } catch (BrokerException ex) {
                        // incrementRefCount throws a BrokerException
                        // if the destination was destroyed
                        // if we are here then the destination went away
                        // try to get the destination again
                        d = null;
                    }
               }
               if (d == null)
                   throw new BrokerException("Unable to attach to destination "
                        + duid);
           }
        } catch (IOException ex) {
            throw new BrokerException("Unable to autocreate destination " +
                   duid , ex);
        }

        try {
            // OK, if we made it here, we have incremented the reference
            // count on the object, we need to make sure we decrement the RefCount
            // before we exit (so cleanup can occur)
            if (!c.getDestinationUID().isQueue() &&
               (! (c instanceof Subscription)) &&
               c.getSubscription() == null) {
                // directly send messages
                c.setFalconRemote(true);
            } else {
                int mp = (d == null ? -1 : d.getMaxPrefetch());
                if (mp <= 0 || mp > BTOBFLOW) mp = BTOBFLOW;
                int prefetch = c.getRemotePrefetch();
                if (prefetch <= 0 || prefetch > mp) prefetch = mp;
                Subscription sub = c.getSubscription();
                if (sub != null && sub.getShared()) {
                    prefetch = 1;
                }
                c.setPrefetch(prefetch);
            }

             try {
                 if (d == null && c.getSubscription() == null) {
                     //deal with wildcard subscription
                     List dsts = Destination.findMatchingIDs(c.getDestinationUID());
                     if (dsts.isEmpty()) {
                         // no matching destinations
                         //we should already be in the wildcard consumers list
                         // nothing to do
                     } else {
                         Iterator itr  = dsts.iterator();
                         while (itr.hasNext()) {
                             DestinationUID did = (DestinationUID)itr.next();
                             Destination dd = Destination.getDestination(did);
                             try {
                             dd.addConsumer(c, false);
                             } catch (ConsumerAlreadyAddedException e) {
                             logger.log(logger.INFO, e.getMessage()+" (CLUSTER_ROUTER)");
View Full Code Here

                    // 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);
                        }
                    }
View Full Code Here

                    bkrFS.clearAll(false);

                    // Destination table.
                    Destination[] dstArray = jdbcStore.getAllDestinations(brokerID);
                    for (int i = 0, len = dstArray.length; i < len; i++) {
                        DestinationUID did = dstArray[i].getDestinationUID();
                        Destination dst = bkrFS.getDestination(did);
                        if (dst == null) {
                            // Store the destination if not found
                            bkrFS.storeDestination(dstArray[i]false);
                        }
                    }

                    // Storing messages for each destination.
                    for (int i = 0, len = dstArray.length; i < len; i++) {
                        Enumeration e = jdbcStore.messageEnumeration(dstArray[i]);
                        try {
                        for (; e.hasMoreElements();) {
                            DestinationUID did = dstArray[i].getDestinationUID();
                            Packet message = (Packet)e.nextElement();
                            SysMessageID mid = message.getSysMessageID();

                            // Get interest states for the message; Consumer State table
                            HashMap stateMap = jdbcStore.getInterestStates(did, mid);
View Full Code Here

        if (clearMessages) {
            Iterator itr = dstMap.values().iterator();
            while (itr.hasNext()) {
                Destination dst = (Destination)itr.next();
                DestinationUID dstuid = dst.getDestinationUID();
                try {
                    parent.getMsgStore().releaseMessageDir(dstuid, sync);
                } catch (IOException e) {
                    // log error and continue
                    logger.log(logger.ERROR, br.X_RELEASE_MSGFILE_FAILED,
View Full Code Here

                    bkrFS = new FileStore(instanceRootDir, false);

                    // Destination table.
                    Destination[] dstArray = bkrFS.getAllDestinations();
                    for (int i = 0, len = dstArray.length; i < len; i++) {
                        DestinationUID did = dstArray[i].getDestinationUID();
                        Destination dst = jdbcStore.getDestination(did);
                        if (dst == null) {
                            // Store the destination if not found
                            jdbcStore.storeDestination(dstArray[i], sessionID);
                        }
                    }

                    // Retrieve messages for each destination.
                    for (int i = 0, len = dstArray.length; i < len; i++) {
                        for (Enumeration e = bkrFS.messageEnumeration(dstArray[i]);
                            e.hasMoreElements();) {
                            DestinationUID did = dstArray[i].getDestinationUID();
                            Packet message = (Packet)e.nextElement();
                            SysMessageID mid = message.getSysMessageID();

                            // Get interest states for the message; Consumer State table
                            HashMap stateMap = bkrFS.getInterestStates(did, mid);
View Full Code Here

                Util.close( null, pstmt, null, myex );
            }
        }

        if ( !deleted ) {
            DestinationUID destinationUID = consumer.getDestinationUID();
            throw new BrokerException(
                br.getKString( BrokerResources.E_INTEREST_NOT_FOUND_IN_STORE,
                consumerUID, destinationUID ), Status.NOT_FOUND );
        }
    }
View Full Code Here

        // make sure store is not closed then increment in progress count
        super.checkClosedAndSetInProgress();

        try {
            DestinationUID dstID = dst.getDestinationUID();
            HashMap data = new HashMap(2);
            data.put( DestMetricsCounters.CURRENT_MESSAGES,
                new Integer(msgStore.getMessageCount(dstID)) );
            data.put( DestMetricsCounters.CURRENT_MESSAGE_BYTES,
                new Long(msgStore.getByteCount(dstID)) );
View Full Code Here

            // Make sure dst exists; autocreate if possible
            Destination dst = Destination.getDestination(
                pkt.getDestination(),
                pkt.getIsQueue() ? DestType.DEST_TYPE_QUEUE
                : DestType.DEST_TYPE_TOPIC, true, true);
            DestinationUID did = dst.getDestinationUID();

            // Load all msgs inorder to verify if any msgs are missing
            if (!dstLoadedSet.contains(dst)) {
                dst.load();
                dstLoadedSet.add(dst); // Keep track of what has been loaded
View Full Code Here

TOP

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

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.