Package com.sun.messaging.jmq.jmsserver.data

Examples of com.sun.messaging.jmq.jmsserver.data.TransactionWork


            
            

             try{
             Globals.getStore().txnLogSharedLock.lock();
             TransactionWork txnWork=null;
             if(Globals.isNewTxnLogEnabled())
             {                     
                txnWork = getTransactionWork2(plist, cmap, sToCmap);         
             }
                    
View Full Code Here


             }
    }

             TransactionWork getTransactionWork2(List plist, HashMap cmap,
      HashMap sToCmap) {
    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;

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

            }

          } catch (Exception ex) {
            logger.logStack(Logger.ERROR,
View Full Code Here

 
  private boolean calculateStoredRouting(BaseTransaction baseTxn)throws BrokerException
  {
    boolean sentMessagesNeedLogging = false;
    // only need to log if message is persistent
    TransactionWork txnWork = baseTxn.getTransactionWork();
    List<TransactionWorkMessage> sentMessages = txnWork.getSentMessages();
    if (sentMessages != null) {
      Iterator<TransactionWorkMessage> iter = sentMessages.iterator();
      while (iter.hasNext()) {
        TransactionWorkMessage twm = iter.next();
        sentMessagesNeedLogging |= calculateStoredRouting(twm);
      }
    }
    boolean ackedMessagesNeedLogging = false;
    List<TransactionWorkMessageAck> ackedMessages = txnWork
        .getMessageAcknowledgments();
    if (ackedMessages != null) {
      Iterator<TransactionWorkMessageAck> ackIter = ackedMessages
          .iterator();
      while (ackIter.hasNext()) {
View Full Code Here

    DataInputStream dis = new DataInputStream(bais);

    localTransaction = new LocalTransaction();
    dis.skip(2);
    localTransaction.getTransactionDetails().readContent(dis);
    TransactionWork work = new TransactionWork();
    work.readWork(dis);
    localTransaction.setTransactionWork(work);
    dis.close();
    bais.close();
  }
View Full Code Here

    DataInputStream dis = new DataInputStream(bais);

    localTransaction = new LocalTransaction();
    dis.skip(2);
    localTransaction.getTransactionDetails().readContent(dis);
    TransactionWork work = new TransactionWork();
    work.readWork(dis);
    localTransaction.setTransactionWork(work);

    // need to write transaction info here
    int objectBodySize = dis.readInt();
View Full Code Here

    clusterTransaction.getTransactionDetails().readContent(dis);
    if (Store.getDEBUG()) {
      Globals.getLogger().log(Logger.DEBUG,
          getPrefix() + "read details "+ clusterTransaction.getTransactionDetails());
    }
    TransactionWork work = new TransactionWork();
    work.readWork(dis);
    clusterTransaction.setTransactionWork(work);

    int objectBodySize = dis.readInt();

    byte[] objectBody = new byte[objectBodySize];
View Full Code Here

      ts.setState(TransactionState.STARTED);

      // TransactionState
      fileStore.storeTransaction(id, ts, true);

      TransactionWork txnWork = baseTxn.getTransactionWork();
      if (txnWork != null)
        convertWork(txnWork, ts, id);

      ts.setState(TransactionState.PREPARED);
      fileStore.updateTransactionState(id, ts, true);
View Full Code Here

      ts.setState(TransactionState.STARTED);

      // TransactionState
      fileStore.storeTransaction(id, ts, true);

      TransactionWork txnWork = baseTxn.getTransactionWork();
      if (txnWork != null)
        convertWork(txnWork, ts, id);

      store.updateClusterTransaction(id, clusterTxn
          .getTransactionBrokers(), Destination.PERSIST_SYNC);
View Full Code Here

    return existingTxn;

  }
 
  protected void messageListLogged(BaseTransaction baseTxn) {
    TransactionWork txnWork = baseTxn.getTransactionWork();
    if (txnWork != null) {
      List<TransactionWorkMessage> sentMessages = txnWork
          .getSentMessages();
      if (sentMessages != null) {
        transactionLogManager.loggedMessageHelper
            .messageListLogged(sentMessages);
      }
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.jmsserver.data.TransactionWork

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.