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

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


  Iterator iter = consumerIDs.iterator();

  int i = 0;
  while (iter.hasNext()) {
      ConsumerUID cid = (ConsumerUID)iter.next();
      long conID = cid.longValue();
      String id;

      try  {
                id = Long.toString(conID);
View Full Code Here


    int numStoredInterests = dis.readInt();
    storedInterests = new ConsumerUID[numStoredInterests];
    for (int j = 0; j < numStoredInterests; j++) {
      long cuid = dis.readLong();
      storedInterests[j] = new ConsumerUID(cuid);
    }

    // Make sure dest exists; auto-create if possible
    // this is because we will need to add messages to this
    // destination
View Full Code Here

      return (new Integer(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
View Full Code Here

  if (consumers == null)  {
      return (null);
  }

  while (consumers.hasNext()) {
      ConsumerUID cid = (ConsumerUID)consumers.next();
      Consumer oneCon = Consumer.getConsumer(cid);

      if (oneCon.isWildcard())  {
    DestinationUID id = oneCon.getDestinationUID();
          al.add(id.getName());
View Full Code Here

                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,
                                        "Fault injection of closing connection");
                            }
                            r1 =s.ackMessage(intid, sysid, id, remoteNotified, true);
                            if (r1 != null) {
                                if (fi.FAULT_INJECTION) {
                                    fi.checkFaultAndExit(FaultInjection.FAULT_TXN_COMMIT_1_7, null, 2, false);
                                }
                                dst.removeMessage(ref.getSysMessageID(),
                                    RemoveReason.ACKNOWLEDGED);
                            } else {
                                s = Session.getSession(intid);
                            }
                        }
                        if (s == null) {
                            //OK the session has been closed, we need
                            // to retrieve the message and acknowledge it
                            // with the stored UID
                            try {
                                if (ref.acknowledged(intid, sid,
                                    true, true, id, remoteNotified, true)) {
                                    dst.removeMessage(ref.getSysMessageID(),
                                        RemoveReason.ACKNOWLEDGED);
                                }
                            } catch (BrokerException ex) {
                                // XXX improve internal error
                                logger.log(Logger.WARNING,"Internal error", ex);
                            }
                        }

                        if (Globals.txnLogEnabled()) {
                            if (cLogDstList == null) {
                                cLogDstList = new ArrayList();
                                cLogMsgList = new ArrayList();
                                cLogIntList = new ArrayList();
                            }

                            // keep track for consumer txn log;
                            // ignore non-durable subscriber
                            if (!dst.isQueue() && !sid.shouldStore()) {
                                continue;
                            }

                            cLogRecordCount++;
                            cLogDstList.add(dst.getUniqueName());
                            cLogMsgList.add(sysid);
                            cLogIntList.add(sid);
                        }
                    } catch (Exception ex) {
                        processDone = false;
                        logger.logStack(Logger.ERROR,BrokerResources.E_INTERNAL_BROKER_ERROR,
                            "-------------------------------------------" +
                            "Processing Acknowledgement during committ [" +
                            sysid + ":" + intid + ":" + con.getConnectionUID()+
                            "]\nReference is " + (ref == null ? null : ref.getSysMessageID())
                            + "\n" + com.sun.messaging.jmq.jmsserver.util.PacketUtil.dumpPacket(msg)
                            + "--------------------------------------------",
                            ex);
                    }
                }
            }
        }

       
        if(Globals.isNewTxnLogEnabled())
        {
          // notify that transaction work has been written to message store
           loggedCommitWrittenToMessageStore(id, transactionType);
        }
              

        // OK .. now remove the acks .. and free up the id for ues
        // XXX Fixed 6383878, memory leaks because txn ack can never be removed
        // from the store if the txn is removed before the ack; this is due
        // to the fack that in 4.0 when removing the ack, the method check
        // to see if the txn still exits in the cache. This temporary fix
        // will probably break some HA functionality and need to be revisited.
        translist.removeTransaction(id, (!processDone ||
                    (cmap.size()>0 && BrokerStateHandler.shuttingDown)));
        if (conlist == null) { //from admin
            logger.log(logger.WARNING,
            BrokerResources.W_ADMIN_COMMITTED_TXN, id, ((xid==null)? "null":xid.toString()));
        }

        // log to txn log if enabled
        try {
            if (pLogRecordByteCount > 0 && cLogRecordCount > 0) {
                // Log all msgs and acks for producing and consuming txn
                ByteArrayOutputStream bos = new ByteArrayOutputStream(
                    (pLogRecordByteCount) +
                    (cLogRecordCount * (32 + SysMessageID.ID_SIZE + 8)) + 16);
                DataOutputStream dos = new DataOutputStream(bos);

                dos.writeLong(id.longValue()); // Transaction ID (8 bytes)

                // Msgs produce section
                dos.writeInt(pLogMsgList.size()); // Number of msgs (4 bytes)
                Iterator itr = pLogMsgList.iterator();
                while (itr.hasNext()) {
                    dos.write((byte[])itr.next()); // Message
                }

                // Msgs consume section
                dos.writeInt(cLogRecordCount); // Number of acks (4 bytes)
                for (int i = 0; i < cLogRecordCount; i++) {
                    String dst = (String)cLogDstList.get(i);
                    dos.writeUTF(dst); // Destination
                    SysMessageID sysid = (SysMessageID)cLogMsgList.get(i);
                    sysid.writeID(dos); // SysMessageID
                    ConsumerUID intid = (ConsumerUID)cLogIntList.get(i);
                    dos.writeLong(intid.longValue()); // ConsumerUID
                }

                dos.close();
                bos.close();
                Globals.getStore().logTxn(
                    TransactionLogType.PRODUCE_AND_CONSUME_TRANSACTION,
                    bos.toByteArray());
            } else if (pLogRecordByteCount > 0) {
                // Log all msgs for producing txn
                ByteBuffer bbuf = ByteBuffer.allocate(pLogRecordByteCount + 12);
                bbuf.putLong(id.longValue()); // Transaction ID (8 bytes)
                bbuf.putInt(pLogMsgList.size()); // Number of msgs (4 bytes)
                Iterator itr = pLogMsgList.iterator();
                while (itr.hasNext()) {
                    bbuf.put((byte[])itr.next()); // Message
                }
                Globals.getStore().logTxn(
                    TransactionLogType.PRODUCE_TRANSACTION, bbuf.array());
            } else if (cLogRecordCount > 0) {
                // Log all acks for consuming txn
                ByteArrayOutputStream bos = new ByteArrayOutputStream(
                    (cLogRecordCount * (32 + SysMessageID.ID_SIZE + 8)) + 12);
                DataOutputStream dos = new DataOutputStream(bos);
                dos.writeLong(id.longValue()); // Transaction ID (8 bytes)
                dos.writeInt(cLogRecordCount); // Number of acks (4 bytes)
                for (int i = 0; i < cLogRecordCount; i++) {
                    String dst = (String)cLogDstList.get(i);
                    dos.writeUTF(dst); // Destination
                    SysMessageID sysid = (SysMessageID)cLogMsgList.get(i);
                    sysid.writeID(dos); // SysMessageID
                    ConsumerUID intid = (ConsumerUID)cLogIntList.get(i);
                    dos.writeLong(intid.longValue()); // ConsumerUID
                }
                dos.close();
                bos.close();
                Globals.getStore().logTxn(
                    TransactionLogType.CONSUME_TRANSACTION, bos.toByteArray());
View Full Code Here

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

                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) {
View Full Code Here

                // 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);
                }
            }
        }

        if (DEBUG) {
           logger.log(logger.INFO, "redeliverUnacked:tid="+tid+", sendMap#="+sendMap.size());
        }

        // OK -> now we have a NEW hashmap id -> messages (sorted)
        // lets resend the ones we can to the consumer
        ArrayList updatedRefs = new ArrayList();
        Iterator sitr = sendMap.entrySet().iterator();
        while (sitr.hasNext()) {
            Map.Entry entry = (Map.Entry)sitr.next();
            ConsumerUID intid = (ConsumerUID)entry.getKey();
            ConsumerUID stored = (ConsumerUID)sToCmap.get(intid);
            if (stored == null) {
                stored = intid;
            }
            SortedSet ss = (SortedSet)entry.getValue();
View Full Code Here

        Logger logger = Globals.getLogger();

        Iterator sitr = sendMap.entrySet().iterator();
        while (sitr.hasNext()) {
            Map.Entry entry = (Map.Entry)sitr.next();
            ConsumerUID intid = (ConsumerUID)entry.getKey();
            ConsumerUID storedID =(ConsumerUID) sToCmap.get(intid);

            SortedSet ss = (SortedSet)entry.getValue();
            Iterator itr = ss.iterator();
            while (itr.hasNext()) {
                PacketReference ref = (PacketReference)itr.next();
View Full Code Here

            StringBuffer remoteConsumerUIDs = new StringBuffer();
            String uidstr = null;
            StringBuffer debugbuf =  new StringBuffer();
            for (int j = 0; j < mcll[0].size(); j++) {
                SysMessageID sysid = (SysMessageID)mcll[0].get(j);
                ConsumerUID  uid = (ConsumerUID)mcll[1].get(j);
                ConsumerUID suid = (ConsumerUID)sToCmap.get(uid);
                if (suid == null || suid.equals(uid)) {
                    continue;
                }
                if (e.isRemote()) {
                    uidstr = String.valueOf(uid.longValue());
                    if (!remoteConsumerUIDa.contains(uidstr)) {
                        remoteConsumerUIDa.add(uidstr);
                        remoteConsumerUIDs.append(uidstr);
                        remoteConsumerUIDs.append(" ");
                        Consumer c = Consumer.getConsumer(uid);
                        if (c != null) {
                            c.recreationRequested();
                        } else {
                            logger.log(logger.WARNING, "Consumer "+uid +
                            " not found in processing remote exception on preparing transaction "+id);
                        }
                    }
                }
                debugbuf.append("\n\t["+sysid+":"+uid+"]");
            }
            if (e.isRemote()) {
                e.setRemoteConsumerUIDs(remoteConsumerUIDs.toString());
                if (DEBUG_CLUSTER_TXN) {
                logger.log(logger.INFO,
                "doRemotePrepare: JMQRemote Exception:remoteConsumerUIDs="+remoteConsumerUIDs+", remote broker "+ba);
                }
            }

            try {
            translist.updateState(id, TransactionState.FAILED, false, TransactionState.PREPARED, true);
            } catch (Exception ex) {
            logger.logStack(logger.WARNING,
            "Unable to update transaction "+id+ " state to FAILED on PREPARE failure from "
            +ba+": "+ex.getMessage()+debugbuf.toString(), ex);
            throw e;
            }

            if (e instanceof AckEntryNotFoundException) {
                mcll = ((AckEntryNotFoundException)e).getAckEntries();
            }

            for (int j = 0; j < mcll[0].size(); j++) {
                SysMessageID sysid = (SysMessageID)mcll[0].get(j);
                ConsumerUID  uid = (ConsumerUID)mcll[1].get(j);
                boolean remove = true;
                if (e instanceof BrokerDownException) {
                    ConsumerUID suid = (ConsumerUID)sToCmap.get(uid);
                    if (suid == null || suid.equals(uid)) {
                        if (DEBUG_CLUSTER_TXN) {
                        logger.log(logger.INFO,
                        "doRemotePrepare: no remove txnack "+sysid+", "+uid+ " for BrokerDownException from "+ba);
                        }
                        remove = false;
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.