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

Examples of com.sun.messaging.jmq.jmsserver.core.Destination$ReconnectReaperTask


   * Create DestinationMonitor MBeans
   */
  List dests = DestinationUtil.getVisibleDestinations();
  if (dests.size() != 0)  {
            for (int i =0; i < dests.size(); i ++) {
                Destination d = (Destination)dests.get(i);

    registerDestination(d);
            }
  }

View Full Code Here


            if (duid == null) {
                throw new BrokerException(Globals.getBrokerResources().getString(
                    BrokerResources.X_INTERNAL_EXCEPTION,
                    "checkPermission() can't get destination uid for " + destination));
            }
            Destination d = Destination.getDestination(duid);
            if (d != null && !d.isAutoCreated()) {
                return;
            }
            acdestination = null;
        }
        checkPermission(con, service, serviceType,
View Full Code Here

                String dest = (String)prop.get("JMQDestination");
                int dtype = ((Integer)prop.get("JMQDestType")).intValue();
                if (id == PacketType.CREATE_DESTINATION) {
                    if (!checkForAutoCreate(dest, dtype)) return;
                    DestinationUID duid = DestinationUID.getUID(dest, DestType.isQueue(dtype));
                    Destination d = Destination.getDestination(duid);
                    if (d != null) return;
                    if (DestType.isQueue(dtype) && DestType.isTemporary(dtype)) return;
                    String[] args = {Thread.currentThread().getName(),
                                     dest, service.toString(), sr.toString(true)};
                    String emsg = Globals.getBrokerResources().getKString(
View Full Code Here

                    boolean hasconsumer = false;
                    boolean notifyadded = false;
                    ConsumerInfoRequestEvent e =  (ConsumerInfoRequestEvent)o;
                    Iterator itr = Destination.getAllDestinations();
                    while (itr.hasNext()) {
                        Destination d = (Destination)itr.next();
                        if (d.isInternal()) {
                            continue;
                        }
                        if ((!e.duid.isWildcard() && d.getDestinationUID().equals(e.duid))) {
                            foundmatch = true;
                            if (d.getAllActiveConsumerCount() == 0) {
                                notifications.put(d.getDestinationUID(),
                                                  new ConsumerInfoNotification(
                                                  d.getDestinationUID(),
                                                  d.getType(), CONSUMER_NOT_READY,
                                                  ((ConsumerInfoRequestEvent)o).infoType, true));
                                notifyadded = true;
                                break;
                            }
                            hasconsumer = true;
                            Iterator itrr = d.getAllActiveConsumers().iterator();
                            while (itrr.hasNext()) {
                                Consumer c = (Consumer)itrr.next();
                                IMQConnection conn = (IMQConnection)cm.getConnection(c.getConnectionUID());
                                BrokerAddress ba = c.getConsumerUID().getBrokerAddress();
                                if ((conn != null && conn.isConnectionStarted()) ||
                                     (ba != null && ba != Globals.getMyAddress())) {
                                    notifications.put(d.getDestinationUID(),
                                                      new ConsumerInfoNotification(
                                                      d.getDestinationUID(),
                                                      d.getType(), CONSUMER_READY,
                                                      ((ConsumerInfoRequestEvent)o).infoType, true));
                                    notifyadded = true;
                                    break;
                                }
                            }
                            break;
                        }
                        if (e.duid.isWildcard() && DestinationUID.match(d.getDestinationUID(), e.duid)) {
                            foundmatch = true;
                            if (d.getAllActiveConsumerCount() == 0) {
                                continue;
                            }
                            hasconsumer = true;
                            Iterator itrr = d.getAllActiveConsumers().iterator();
                            while (itrr.hasNext()) {
                                Consumer c = (Consumer)itrr.next();
                                IMQConnection conn = (IMQConnection)cm.getConnection(c.getConnectionUID());
                                BrokerAddress ba = c.getConsumerUID().getBrokerAddress();
                                if ((conn != null && conn.isConnectionStarted()) ||
                                     (ba != null && ba != Globals.getMyAddress())) {
                                    notifications.put(d.getDestinationUID(),
                                                  new ConsumerInfoNotification(
                                                  d.getDestinationUID(),
                                                  e.destType, CONSUMER_READY,
                                                  ((ConsumerInfoRequestEvent)o).infoType, true));
                                    notifyadded = true;
                                    break;
                                }
View Full Code Here

            status = Status.ERROR;
  }

        if (destination != null) {
            try {
                Destination d= Destination.getDestination(destination,
                          DestType.isQueue(destType.intValue()));

                if (d != null) {
                    if (DEBUG) {
                        d.debug();
                    }

        /*
         * Delete message here
         */
                    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  {
      /*
                        errMsg= rb.getString(rb.X_MSG_NOT_FOUND, msgID);
      */
                        errMsg= "Could not locate message "
View Full Code Here

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

        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

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

                      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 "+
                                            "[" + cid + "," + sid + "," + sysid+"]"+
View Full Code Here

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

                // route each message to the destination
                // this puts it on the pending list
                try {
                    d.forwardOrphanMessages(ss, storedID);
                    sitr.remove();
                } catch (Exception ex) {
                    logger.log(Logger.INFO,"Internal Error: "
                               + "Unable to re-queue message "
                               + " to queue " + d, ex);
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.jmsserver.core.Destination$ReconnectReaperTask

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.