Examples of PacketReference


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

  DestMetricsCounters dmc = d.getMetrics();
  return (new Long(dmc.getHighWaterMessageBytes()));
    }

    public String getNextMessageID() {
        PacketReference ref = d.peekNext();
        if (ref != null) {
            return ref.getSysMessageID().toString();
        } else {
            return "";
       }
    }
View Full Code Here

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

         */
                    logger.log(Logger.INFO, "Deleting message ID: " + msgID);

        SysMessageID sysMsgID = SysMessageID.get(msgID);

                    PacketReference pr = Destination.get(sysMsgID);

        if (pr != null)  {
            d.removeMessage(sysMsgID, RemoveReason.REMOVED_OTHER);
        } else  {
      /*
 
View Full Code Here

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

        // OK .. handle producer transaction
        int pLogRecordByteCount = 0;
        ArrayList pLogMsgList = null;
        for (int i =0; plist != null && i < plist.size(); i ++ ) {
            SysMessageID sysid = (SysMessageID)plist.get(i);
            PacketReference ref = Destination.get(sysid);
            if (ref == null) {
                logger.log(Logger.ERROR,BrokerResources.E_INTERNAL_BROKER_ERROR,  "transacted message removed too early "+sysid);
                continue;
            }
                    
            // handle forwarding the message
            try {
                if (Globals.txnLogEnabled()) {
                    if (pLogMsgList == null) {
                        pLogMsgList = new ArrayList();
                    }

                    // keep track for producer txn log
                    pLogRecordByteCount += ref.getSize();
                    pLogMsgList.add(ref.getPacket().getBytes());
                }

                Destination d = Destination.getDestination(ref.getDestinationUID());
                if (fi.FAULT_INJECTION) {
                    fi.checkFaultAndExit(FaultInjection.FAULT_TXN_COMMIT_1_6, null, 2, false);
                }
                Set s = d.routeNewMessage(ref);
                d.forwardMessage(s,ref);

             } catch (Exception ex) {
                 logger.logStack((BrokerStateHandler.shuttingDown? Logger.DEBUG : Logger.ERROR),BrokerResources.E_INTERNAL_BROKER_ERROR, "unable to route/send transaction message " + sysid , ex);
             }

        }

        boolean processDone = true;

        // handle consumer transaction
        int cLogRecordCount = 0;
        ArrayList cLogDstList = null;
        ArrayList cLogMsgList = null;
        ArrayList cLogIntList = null;
        HashMap remoteNotified = new HashMap();
        if (cmap != null && cmap.size() > 0) {
            Iterator itr = cmap.entrySet().iterator();
            while (itr.hasNext()) {
                Map.Entry entry = (Map.Entry)itr.next();
                SysMessageID sysid = (SysMessageID)entry.getKey();
                // CANT just pull from connection
                if (sysid == null) continue;
                PacketReference ref = Destination.get(sysid);
                if (ref == null || ref.isDestroyed() || ref.isInvalid()) {
                    // already been deleted .. ignore
                    continue;
                }

                Destination dst =
                    Destination.getDestination(ref.getDestinationUID());

                List interests = (List) entry.getValue();
                for (int i = 0; i < interests.size(); i ++) {
                    ConsumerUID intid = (ConsumerUID) interests.get(i);
                    ConsumerUID sid = (ConsumerUID)sToCmap.get(intid);
                    if (sid == null) sid = intid;

                    try {
                        Session s = Session.getSession(intid);
                        if (s != null) {
                            PacketReference r1 = null;
                            if (fi.FAULT_INJECTION && fi.checkFault(
                                FaultInjection.FAULT_TXN_COMMIT_1_7_1, null)) {
                                Globals.getConnectionManager().getConnection(
                                        s.getConnectionUID()).destroyConnection(
                                        true, GoodbyeReason.OTHER,
View Full Code Here

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

    // iterate over messages produced in this transaction
    // NB should we be checking for persistent messages?
    for (int i = 0; plist != null && i < plist.size(); i++) {
      SysMessageID sysid = (SysMessageID) plist.get(i);
      PacketReference ref = Destination.get(sysid);
      if (ref == null) {
        logger.log(Logger.ERROR,
            BrokerResources.E_INTERNAL_BROKER_ERROR,
            "transacted message removed too early " + sysid);
        continue;
      }
      try {
        if (ref.isPersistent()) {
          TransactionWorkMessage txnWorkMessage = new TransactionWorkMessage();
          Destination dest = ref.getDestination();
          txnWorkMessage.setDestUID(dest.getDestinationUID());
          txnWorkMessage.setPacketReference(ref);
         
          txnWork.addMesage(txnWorkMessage);
        }

      } catch (Exception ex) {
        logger.logStack((BrokerStateHandler.shuttingDown ? Logger.DEBUG
            : Logger.ERROR),
            BrokerResources.E_INTERNAL_BROKER_ERROR,
            "unable to log transaction message " + sysid, ex);
      }
    }

    // iterate over messages consumed in this transaction
    if (cmap != null && cmap.size() > 0) {

      Iterator itr = cmap.entrySet().iterator();
      while (itr.hasNext()) {
        Map.Entry entry = (Map.Entry) itr.next();

        SysMessageID sysid = (SysMessageID) entry.getKey();
        List interests = (List) entry.getValue();

        if (sysid == null)
          continue;

        PacketReference ref = Destination.get(sysid);
        if (ref == null || ref.isDestroyed() || ref.isInvalid()) {
          // already been deleted .. ignore
          continue;
        }
       
        // Do we want to store acknowledgements for remote brokers?
        // If this is a local transaction, then all acks should be local.
        // If this is a cluster transaction, then acks for remote messages
        // will be forwarded to remote brokers as part of the protocol.
        // The cluster txn should only need op store the addresses of the brokers involved.
        if(!ref.isLocal())
        {
          continue;
        }

        Destination dst = Destination.getDestination(ref
            .getDestinationUID());

        // A bit unlikely, but a message may have been consumed multiple
        // times in the same transaction by different consumers
        // - hence the list.
        for (int i = 0; i < interests.size(); i++) {
          ConsumerUID intid = (ConsumerUID) interests.get(i);
          ConsumerUID sid = (ConsumerUID) sToCmap.get(intid);
          if (sid == null)
            sid = intid;

          try {
            // ignore non-durable subscriber
            if (!dst.isQueue() && !sid.shouldStore()) {
              continue;
            }
            if (ref.isPersistent()) {
              TransactionWorkMessageAck ack = new TransactionWorkMessageAck();
              ack.setConsumerID(sid);
              ack.setDest(dst.getDestinationUID());
              ack.setSysMessageID(sysid);
              txnWork.addMessageAcknowledgement(ack);
View Full Code Here

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

  }
 
  private boolean calculateStoredRouting(TransactionWorkMessage twm)
      throws BrokerException {
    boolean requiresLogging = false;
    PacketReference ref = twm.getPacketReference();
   
    Destination dest = Destination.getDestination(twm.getDestUID());
    ConsumerUID[] storedInterests = null;
    if(dest==null)
    {
      String msg = "Could not find destination for "+twm.getDestUID() + " refDest= "+ref.getDestinationName();
      logger.log(Logger.ERROR,msg);
      throw new BrokerException(msg);
     
    }
    try {
      storedInterests = dest.calculateStoredInterests(ref);
      twm.setStoredInterests(storedInterests);

    } catch (SelectorFormatException sfe) {
      throw new BrokerException(
          "Could not route transacted message on commit", sfe);
    }
    if (storedInterests != null)
    {
      if (DEBUG_CLUSTER_TXN)
        {
          logger.log(Logger.DEBUG, Thread.currentThread().getName() +" stored routing = null "+twm +" persist="+ref.isPersistent());
        }
      return true;
    }
    else{
      if (DEBUG_CLUSTER_TXN)
View Full Code Here

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

            SysMessageID sysid = (SysMessageID)list.get(i);
            if (DEBUG) {
                logger.log(Logger.DEBUG,"Removing " +
                      sysid + " because of rollback");
            }
            PacketReference ref = Destination.get(sysid);
            if (ref == null) continue;
            DestinationUID duid = ref.getDestinationUID();
            Destination d = Destination.getDestination(duid);
            d.removeMessage(sysid, RemoveReason.ROLLBACK);
        }

        // remove from our active connection list
        if (conlist != null) {
            conlist.remove(id);
        }

        // re-queue any orphan messages

        // how we handle the orphan messages depends on a couple
        // of things:
        //   - has the session closed ?
        //     if the session has closed the messages are "orphan"
        //   - otherwise, the messages are still "in play" and
        //     we dont do anything with them
        //
        Map m = translist.getOrphanAck(id);
        if (m != null) {
            Iterator itr = m.entrySet().iterator();
            while (itr.hasNext()) {
                Map.Entry me = (Map.Entry)itr.next();
                SysMessageID sysid = (SysMessageID)me.getKey();
                PacketReference ref = Destination.get(sysid, false);
                if (ref == null) {
                    logger.log(Logger.DEBUG,id + ":Unknown orphan " + sysid);
                    continue;
                }
                Map sids = (Map)me.getValue();
                if (sids == null) continue;

                Iterator siditr = sids.entrySet().iterator();
                while (siditr.hasNext()) {
                    Map.Entry se = (Map.Entry)siditr.next();
                    ConsumerUID sid = (ConsumerUID)se.getKey();
                    if (ref.isLocal()) {
                        ref.getDestination().forwardOrphanMessage(ref, sid);
                        continue;
                    }
                    List cids = (List)se.getValue();
                    if (cids == null) continue;

                    Iterator ciditr = cids.iterator();
                    while (ciditr.hasNext()) {
                        ConsumerUID cid = (ConsumerUID)ciditr.next();
                        try {
                            if (ref.acknowledged(cid, sid,
                                                 !(cid.isNoAck()||cid.isDupsOK()),
                                                 false, id, null, false)) {
                                Destination d = ref.getDestination();
                                d.removeRemoteMessage(sysid, RemoveReason.ACKNOWLEDGED, ref);
                            }
                        } catch(Exception ex) {
                            logger.logStack((DEBUG_CLUSTER_TXN ? Logger.WARNING:Logger.DEBUG),
                                            "Unable to cleanup orphaned remote message "+
View Full Code Here

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

                // for each message, get the ref
                Map.Entry entry = (Map.Entry)itr.next();
                SysMessageID sysid = (SysMessageID)entry.getKey();
                // CANT just pull from connection
                if (sysid == null) continue;
                PacketReference ref = Destination.get(sysid, false);

                if (ref == null || ref.isDestroyed() ||
                      ref.isInvalid())  {
                      // already been deleted .. ignore
                      if (DEBUG) {
            logger.log(logger.INFO, "redeliverUnacked:tid="+tid+": ref="+ref+" already deleted");
                      }
                      continue;
                }
                if (ref.isOverrided()) continue;

                // now get the interests and stick each message
                // in a list specific to the consumer
                // the list is automatically sorted
                List interests = (List) entry.getValue();
                for (int i = 0; i < interests.size(); i ++) {
                    ConsumerUID intid = (ConsumerUID) interests.get(i);
                    ConsumerUID stored = (ConsumerUID)sToCmap.get(intid);
                    if (stored == null) {
                        stored = intid;
                    }

                    SortedSet ss = (SortedSet)sendMap.get(intid);
                    if (ss == null) {
                        ss = new TreeSet(new RefCompare());
                        sendMap.put(intid, ss);
                    }
                    ref.removeInDelivery(stored);
                    ss.add(ref);
                }
            }
        }
View Full Code Here

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

    }   

    //called from redeliverUnacked for rollback
    private void updateRefsState(ConsumerUID storedCuid, SortedSet refs,
                                 boolean redeliver, List updatedRefs, TransactionUID tid) {
        PacketReference ref = null;
        Iterator itr = refs.iterator();
        while (itr.hasNext()) {
            try {
                ref = (PacketReference)itr.next();
                if (updatedRefs.contains(ref)) {
                    continue;
                }
                if (redeliver) {
                    ref.consumed(storedCuid, false, false);
                } else {
                    ref.removeDelivered(storedCuid, true);
                }
                updatedRefs.add(ref);
            } catch (Exception ex) {
                Object[] args = { "["+ref+", "+storedCuid+"]", tid, ex.getMessage() };
                logger.log(Logger.WARNING, Globals.getBrokerResources().getKString(
View Full Code Here

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

            ConsumerUID storedID =(ConsumerUID) sToCmap.get(intid);

            SortedSet ss = (SortedSet)entry.getValue();
            Iterator itr = ss.iterator();
            while (itr.hasNext()) {
                PacketReference ref = (PacketReference)itr.next();
                SysMessageID sysid = ref.getSysMessageID();
                if (!ref.isLocal()) {
                    if (tid != null && translist != null) {
                        translist.removeOrphanAck(tid, sysid, storedID, intid);
                    }
                   
                    try {
                        if (ref.acknowledged(intid, storedID,
                                             !(intid.isNoAck()||intid.isDupsOK()),
                                             false, tid, null, false)) {
                            Destination d = ref.getDestination();
                            d.removeRemoteMessage(sysid, RemoveReason.ACKNOWLEDGED, ref);
                        }
                    } catch(Exception ex) {
                        logger.logStack((DEBUG_CLUSTER_TXN ? Logger.WARNING:Logger.DEBUG),
                                        "Unable to cleanup remote message "+
                                        "[" + intid + "," + storedID + "," + sysid+"]"+
                                        " on rollback transaction " +tid+" for inactive consumer.", ex);
                    }
                    BrokerAddress addr = null;
                    if (tid != null && translist != null) {
                        addr = translist.getAckBrokerAddress(tid, sysid, intid);
                    } else {
                        addr = ref.getAddress();
                    }
                    try {
                        HashMap prop = new HashMap();
                        if (tid != null) {
                            prop.put(ClusterBroadcast.RB_RELEASE_MSG_INACTIVE, tid.toString());
                        } else {
                            prop.put(ClusterBroadcast.RC_RELEASE_MSG_INACTIVE, "");
                        }
                        Globals.getClusterBroadcast().acknowledgeMessage(
                                                      addr, sysid, intid,
                                                      ClusterBroadcast.MSG_IGNORED,
                                                      prop, false /*no wait ack*/);
                    } catch (BrokerException e) {
                        Globals.getLogger().log(Logger.WARNING,
                        "Unable to notify "+addr+" for remote message "+
                        "["+intid+", "+storedID+", "+", "+sysid+"]"+
                        " in "+(tid != null ? ("rollback transaction "+ tid):("recover"))+" for inactive consumer.");
                    }
                    itr.remove();
                    continue;
                }
            }

            if (storedID == null || intid == storedID) {
                    // non-durable subscriber
                    // ignore
                    sitr.remove();
                   continue;
            }

            if (ss.isEmpty()) {
                if (DEBUG) {
                    logger.log(Logger.INFO, "redeliverUnackedNoConsuemr: "+
                    "empty local message set for consumer "+intid+"[storedID="+storedID+"]");
                }
                continue;
            }

            // see if we are a queue
            if (storedID == PacketReference.getQueueUID()) {
                // queue message on
                // queues are complex ->
                PacketReference ref = (PacketReference)ss.first();

                if (ref == null) {
                    if (DEBUG) {
                        logger.log(Logger.INFO,"Internal Error: "
                           + " null reterence");
                    }
                    continue;
                }
                try {
                    if (redeliver) {
                        ref.consumed(storedID, false, false);
                    } else {
                        ref.removeDelivered(storedID, false);
                    }
                } catch (IOException ex) {
                    logger.log(Logger.WARNING,"Internal error",
                           ex);
                }

                Destination d= ref.getDestination();
                if (d == null) {
                    if (DEBUG) {
                        logger.log(Logger.INFO,"Internal Error: "
                           + " unknown destination for reference: "
                           + ref);
View Full Code Here

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

        ArrayList[] mcll = null;
        boolean hasRemote =  false;
        while (itr.hasNext()) {
            SysMessageID sysid = (SysMessageID)itr.next();
            if (sysid == null) continue;
            PacketReference ref = Destination.get(sysid, false);
            if (checkRefRequeued(id, ref, sysid)) {
                BrokerException bex = new BrokerException(
                   Globals.getBrokerResources().getKString(
                   BrokerResources.X_MESSAGE_MAYBE_REROUTED, sysid)+
                   ", TUID="+id, Status.GONE);
                bex.setRemote(true);
                StringBuffer buf = new StringBuffer();
                List interests = (List)mcmap.get(sysid);
                for (int i = 0 ; i < interests.size(); i++) {
                    buf.append(String.valueOf(((ConsumerUID)interests.get(i)).longValue()));
                    buf.append(" ");
                }
            bex.setRemoteConsumerUIDs(buf.toString());
                throw bex;
            }
      if (ref == null) {
                throw new BrokerException(
                Globals.getBrokerResources().getKString(
                BrokerResources.X_MESSAGE_REF_GONE, sysid)+", TUID="+id, Status.CONFLICT);
            }
            BrokerAddress ba = ref.getAddress();
            if (ba == null) ba = Globals.getMyAddress();
            if (ba != Globals.getMyAddress() && !hasRemote) {
                hasRemote = true;
                if (checkOnly) return new HashMap();
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.