Examples of SysMessageID


Examples of com.sun.messaging.jmq.io.SysMessageID

    // for serializing the object
    public void readExternal(ObjectInput in)
  throws IOException, ClassNotFoundException {

  sysid = new SysMessageID();
  sysid.readID(in);
  iid = (ConsumerUID)in.readObject();
        try {
      sid = (ConsumerUID)in.readObject();
        } catch (Exception ex) { // deal w/ missing field in 3.0.1
View Full Code Here

Examples of com.sun.messaging.jmq.io.SysMessageID

     */
    protected synchronized JMSAck _deliverMessage(
            javax.jms.MessageListener msgListener, JMSPacket jmsPacket,
            long consumerId) {
        JMSAck jmsAck = null;
        SysMessageID messageID = null;
        long xaTxnId = 0L;
        if (this.enableThreadCheck) {
            //Relies on the *same* thread being used to deliver all messages
            //while this sesion is alive
            long tId = Thread.currentThread().getId();
View Full Code Here

Examples of com.sun.messaging.jmq.io.SysMessageID

    protected synchronized javax.jms.Message _fetchMessage(long consumerId,
            long timeout, String methodName)
    throws JMSException {
        JMSPacket jmsPacket = null;
        javax.jms.Message jmsMsg = null;
        SysMessageID messageID = null;
        long xaTxnId = 0L;
        if (false && this.dc.isStopped()) {
            String excMsg = _lgrMID_INF+"consumerId="+consumerId+":"+
                    methodName+":Connection has not been started!";
            _loggerJS.warning(excMsg);
View Full Code Here

Examples of com.sun.messaging.jmq.io.SysMessageID

        } else {
            transactionId = this.transactionId;
        }
        this._acknowledgeMessage(msgPkt, consumerId, transactionId, ackType);
        //Remove the specific message from the UnackedMsgIDs
        SysMessageID _sysMsgID = msgPkt.getReceivedSysMessageID();
        int index = this.unackedMessageIDs.indexOf(_sysMsgID);
        this.unackedMessageIDs.remove(index);
        this.unackedConsumerIDs.remove(index);
    }
View Full Code Here

Examples of com.sun.messaging.jmq.io.SysMessageID

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

Examples of com.sun.messaging.jmq.io.SysMessageID

    TransactionWork txnWork = new TransactionWork();

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

Examples of com.sun.messaging.jmq.io.SysMessageID

        if (fi.FAULT_INJECTION)
            checkFIAfterDB(PacketType.ROLLBACK_TRANSACTION);

        List list = new ArrayList(translist.retrieveSentMessages(id));
        for (int i =0; list != null && i < list.size(); i ++ ) {
            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;
                }
View Full Code Here

Examples of com.sun.messaging.jmq.io.SysMessageID

        if (cmap != null && cmap.size() > 0) {
            Iterator itr = cmap.entrySet().iterator();
            while (itr.hasNext()) {
                // 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() ||
View Full Code Here

Examples of com.sun.messaging.jmq.io.SysMessageID

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

Examples of com.sun.messaging.jmq.io.SysMessageID

            ArrayList remoteConsumerUIDa = new ArrayList();
            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)) {
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.