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

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


        HashMap destNameType) throws BrokerException  {
        HashMap h = new HashMap();
        PacketReference  pr = getPacketReference(sysMsgID);
        Packet  pkt = pr.getPacket();
        HashMap msgHeaders = pr.getHeaders();
        Destination d = pr.getDestination();
        String corrID = pkt.getCorrelationID(), errMsg;
        String destType = DestinationType.QUEUE;
        byte b[] = null;

        h.put("CorrelationID", corrID);

        if (corrID != null)  {
      try  {
                b = corrID.getBytes("UTF8");
      } catch(Exception e)  {
      }
        }

        h.put("CorrelationIDAsBytes", b);

        h.put("DeliveryMode", (pkt.getPersistent()) ?
      new Integer(javax.jms.DeliveryMode.PERSISTENT) :
      new Integer(javax.jms.DeliveryMode.NON_PERSISTENT));

        h.put("DestinationName", pkt.getDestination());

  if (pkt.getIsQueue())  {
            destType = DestinationType.QUEUE;
  } else  {
            destType = DestinationType.TOPIC;
  }

        h.put("DestinationType", destType);

        h.put("Expiration", new Long(pkt.getExpiration()));

        h.put("MessageID", msgHeaders.get("JMSMessageID"));
        h.put("Priority", new Integer(pkt.getPriority()));

        h.put("Redelivered", new Boolean(pkt.getRedelivered()));

  /*
   * The ReplyTo information in the packet contains
   * the destination name and class name (i.e. dest class
   * name), which the broker cannot really use.
   * We need to query/check if:
   *  - the destination exists
   *  - what it's type is
   */
        String replyToDestName = pkt.getReplyTo();

        if (replyToDestName != null)  {
      boolean destFound = false, isQueue = true;

      if (destNameType != null)  {
    Boolean isQ = (Boolean)destNameType.get(replyToDestName);

    if (isQ != null)  {
        isQueue = isQ.booleanValue();
        destFound = true;
    }
      }

      if (!destFound)  {
          try  {
              Destination topic, queue;

              queue = Destination.findDestination(replyToDestName, true);
              topic = Destination.findDestination(replyToDestName, false);

        if ((queue != null) && (topic != null))  {
View Full Code Here


  }

        if (status == Status.OK) {
            try {

                Destination d= Destination.getDestination(destination,
                          DestType.isQueue(destType.intValue()));

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

        d.load();

        SysMessageID sysMsgID = SysMessageID.get(msgID);
                    PacketReference  pr = getPacketReference(sysMsgID);

        if (pr != null)  {
      HashMap hashMapBody = (HashMap)body;

      /*
       * Need to check if message types match
       */
      int oldPacketType = pr.getPacket().getPacketType();
      Integer newPacketType =
        (Integer)hashMapBody.get("MessageBodyType");

      if (oldPacketType != newPacketType.intValue())  {
                            errMsg = "REPLACE_MESSAGE: Existing message and new message types do not match.";
                            logger.log(Logger.ERROR, errMsg);
   
                            status = Status.ERROR;
      } else  {
                byte[] bytes = getBytesFromMessage(hashMapBody);

                newMsgID = d.replaceMessageString(sysMsgID, null,
            bytes);

               if (newMsgID == null)  {
                               errMsg = "REPLACE_MESSAGE: New message ID not returned as expected.";
                               logger.log(Logger.ERROR, errMsg);
View Full Code Here

          tempenum = null;
      }
        } else {
      // get next enumeration
      while (dstitr.hasNext()) {
          Destination dst = (Destination)dstitr.next();
          try {
        // got the next enumeration
            tempenum = messageEnumeration(
            dst.getDestinationUID());
        break;
          } catch (BrokerException e) {
        // log error and try to load messages for
        // the next destionation
        logger.log(Logger.ERROR,
          BrokerResources.X_LOAD_MESSAGES_FOR_DST_FAILED,
          dst.getDestinationUID(), e);
          }
      }
      if (tempenum == null) {
          return false; // no more
      }
View Full Code Here

  }

        if (clearMessages) {
            Iterator itr = dstMap.values().iterator();
            while (itr.hasNext()) {
                Destination dst = (Destination)itr.next();
                DestinationUID did = dst.getDestinationUID();
                parent.getMsgStore().releaseMessageDir(did);
            }
        }
        dstMap.clear();
    }
View Full Code Here

                    Globals.getLogger().log(Logger.INFO,
                    "BrokerConsumers.forwardMessageToRemote(): "+ref+", ignore removed consumer: "+consumer);
                    }
                    try {
                        if (ref.acknowledged(uid, sid, !uid.isDupsOK(), false)) {
                            Destination d=Destination.getDestination(ref.getDestinationUID());
                            d.removeMessage(ref.getSysMessageID(), RemoveReason.ACKNOWLEDGED);
                        }
                    } catch (Exception e) {
                        logger.logStack(Logger.WARNING,
                        "Unable to cleanup message "+ref.getSysMessageID()+" for closed consumer "+uid, e);
                    }
View Full Code Here

          synchronized(removeConsumerLock) {
              c = (Consumer)consumers.remove(uid);
          }
          if (c == null && !cleanup) return;

          Destination d = null;
          if (c != null) {
              c.pause("MultiBroker - removing consumer");
              // remove it from the destination
              d= Destination.getDestination(c.getDestinationUID());

              // quit listening for busy events
              Object listener= listeners.remove(uid);
              if (listener != null) {
                  c.removeEventListener(listener);
              }

              // remove it from the active list
              activeConsumers.remove(c);
          }

          Set destroySet = new LinkedHashSet();
          LinkedHashSet openacks = new LinkedHashSet();
          LinkedHashSet openmsgs = new LinkedHashSet();
          // OK .. get the acks .. if its a FalconRemote
          // we sent the messages directly and must explicitly ack
          synchronized(deliveredMessages) {
              if (c != null) {
                  cleanupList.put(uid, c.getParentList());
              }
              Prioritized cparent = (Prioritized)cleanupList.get(uid);
              if (DEBUG) {
              logger.log(logger.INFO, "BrokerConsumers.removeConsumer:"+uid+
                          ", pending="+pendingMsgs+", cleanup="+cleanup+", cparent="+cparent);
              }
              Iterator itr = deliveredMessages.values().iterator();
              while (itr.hasNext()) {
                  ackEntry e = (ackEntry)itr.next();
                  if (!e.getConsumerUID().equals(uid)) continue;
                  if (e.getTUID() != null) continue;
                  if (pendingMsgs != null && !cleanup) {
                      if (pendingMsgs.contains(e.getSysMessageID())) {
                          continue;
                      }
                  }
                  if (DEBUG && DEBUG_CLUSTER_MSG) {
                      logger.log(logger.DEBUG,
                      "BrokerConsumers.removeConsumer:"+uid+", remove ackEntry="+e+ ", c="+c);
                  }
                  itr.remove();
                  if (c != null) {
                      if (c.isFalconRemote()) {
                          e.acknowledged(false);
                      } else {
                          PacketReference ref = e.getReference();
                          if (ref != null)  {
                              ref.removeInDelivery(e.getStoredConsumerUID());
                              destroySet.add(ref);
                          }
                      }
                      continue;
                  }
                  PacketReference ref = e.getReference();
                  if (ref != null) {
                      ref.removeInDelivery(e.getStoredConsumerUID());
                  }
                  openacks.add(e);
              }
              itr = openacks.iterator();
              while (itr.hasNext()) {
                  ackEntry e = (ackEntry)itr.next();
                  if (cparent == null) {
                      e.acknowledged(false);
                  } else {
                      PacketReference ref = e.getReference();
                      if (ref != null) openmsgs.add(ref);
                  }
              }
              if (cparent != null && openmsgs.size() > 0) {
                  cparent.addAllOrdered(openmsgs);
              }
              if (cleanup || pendingMsgs == null) {
                  cleanupList.remove(uid);
                  pendingConsumerUIDs.remove(uid);
              } else {
                  pendingConsumerUIDs.put(uid, pendingMsgs);
              }
          }

          if (c != null) {
              c.destroyConsumer(destroySet, false, false);
              if (d != null)  {
              d.removeConsumer(uid, false);
              }
          }
    }
View Full Code Here

                com.sun.messaging.jmq.jmsserver.core.ConsumerUID sid = value.getStoredConsumerUID();
                com.sun.messaging.jmq.jmsserver.core.ConsumerUID uid = value.getConsumerUID();
                if (sid== null || sid == uid) {
                    try {
                        if (ref.acknowledged(uid, sid, !uid.isDupsOK(), false)) {
                            Destination d=Destination.getDestination(ref.getDestinationUID());
                            d.removeMessage(ref.getSysMessageID(), RemoveReason.ACKNOWLEDGED);
                        }
                    } catch (Exception e) {
                        logger.logStack(Logger.WARNING,
                        "Unable to cleanup message "+ref.getSysMessageID()+logstrop, e);
                    }
View Full Code Here

                                            Map optionalProps)
                                            throws BrokerException {
        PacketReference ref = Destination.get(sysid);
        if (ref == null) return true;

        Destination d= ref.getDestination();
        if (d == Destination.getDMQ()) {
            // already gone, ignore
            return true;
        }
        // first pull out properties
        String comment = null;
        RemoveReason reason = null;
        Exception ex = null;
        Integer deliverCnt = null;
        Integer reasonInt = null;
        String deadbkr = null;
        if (optionalProps != null) {
            comment = (String)optionalProps.get(DMQ.UNDELIVERED_COMMENT);
            ex = (Exception)optionalProps.get(DMQ.UNDELIVERED_EXCEPTION);
            deliverCnt = (Integer)optionalProps.get(Destination.TEMP_CNT);
            reasonInt = (Integer)optionalProps.get("REASON");
            deadbkr = (String)optionalProps.get(DMQ.DEAD_BROKER);
        }
        RemoveReason rr = null;
        if (ackType == ClusterBroadcast.MSG_UNDELIVERABLE) {
            rr = RemoveReason.UNDELIVERABLE;
        } else {
            rr = RemoveReason.ERROR;
            if (reasonInt != null) {
                rr = RemoveReason.findReason(reasonInt.intValue());
            }
        }
        if (comment == null) comment = "none";
                // OK
        if (ref.markDead(cuid, storedid, comment, ex, rr,
            (deliverCnt == null ? 0 : deliverCnt.intValue()), deadbkr)) {
            if (ref.isDead()) {
                if (DEBUG) {
                    Globals.getLogger().log(logger.INFO,
                    "Remove dead message "+sysid+
                    " for remote consumer "+ cuid +" on destination "+d+" with reason "+rr);
                }
                try {
                    d.removeDeadMessage(ref);
                } catch (Exception e) {
                    logger.log(logger.WARNING,
                    "Unable to remove dead["+rr+", "+deadbkr+"] message "+ref+"["+cuid+"]: "+e.getMessage(), e);
                }
            }
View Full Code Here

                        cLogIntList = new ArrayList();
                    }

                    PacketReference ref = Destination.get(sysid);
                    if (ref != null && !ref.isDestroyed() && !ref.isInvalid()) {
                        Destination dst = Destination.getDestination(ref.getDestinationUID());
                        dstName = dst.getUniqueName();
                    }
                }

                if (acknowledgeMessageFromRemote(ackType, sysid, cuid, optionalProps)) {
                    if (dstName != null) {
View Full Code Here

        DestinationUID duid = c.getDestinationUID();

        int type = (duid.isQueue() ? DestType.DEST_TYPE_QUEUE :
                     DestType.DEST_TYPE_TOPIC);

        Destination d= null;

        try {
            // ok handle adding a reference count
            // we'll try at most 2 times to get a
            // destination

            if (duid.isWildcard()) {
                d = null;

            } else {
                for (int i=0; i < 2 && d == null ; i ++) {
                    d = Destination.getDestination(duid.getName(),
                      type, true, true);
   
                    try {
                        // increment the reference count
                        // this make sure that the destination
                        // is not removed by autocreate prematurely   
                        if (d != null) {
                            d.incrementRefCount();
   
                            break; // well we should break anyway, but
                                   // this makes it explicit
                        }
   
                    } catch (BrokerException ex) {
                        // incrementRefCount throws a BrokerException
                        // if the destination was destroyed
                        // if we are here then the destination went away
                        // try to get the destination again
                        d = null;
                    }
               }
               if (d == null)
                   throw new BrokerException("Unable to attach to destination "
                        + duid);
           }
        } catch (IOException ex) {
            throw new BrokerException("Unable to autocreate destination " +
                   duid , ex);
        }

        try {
            // OK, if we made it here, we have incremented the reference
            // count on the object, we need to make sure we decrement the RefCount
            // before we exit (so cleanup can occur)
            if (!c.getDestinationUID().isQueue() &&
               (! (c instanceof Subscription)) &&
               c.getSubscription() == null) {
                // directly send messages
                c.setFalconRemote(true);
            } else {
                int mp = (d == null ? -1 : d.getMaxPrefetch());
                if (mp <= 0 || mp > BTOBFLOW) mp = BTOBFLOW;
                int prefetch = c.getRemotePrefetch();
                if (prefetch <= 0 || prefetch > mp) prefetch = mp;
                Subscription sub = c.getSubscription();
                if (sub != null && sub.getShared()) {
                    prefetch = 1;
                }
                c.setPrefetch(prefetch);
            }

             try {
                 if (d == null && c.getSubscription() == null) {
                     //deal with wildcard subscription
                     List dsts = Destination.findMatchingIDs(c.getDestinationUID());
                     if (dsts.isEmpty()) {
                         // no matching destinations
                         //we should already be in the wildcard consumers list
                         // nothing to do
                     } else {
                         Iterator itr  = dsts.iterator();
                         while (itr.hasNext()) {
                             DestinationUID did = (DestinationUID)itr.next();
                             Destination dd = Destination.getDestination(did);
                             try {
                             dd.addConsumer(c, false);
                             } catch (ConsumerAlreadyAddedException e) {
                             logger.log(logger.INFO, e.getMessage()+" (CLUSTER_ROUTER)");
                             }
                         }
                     }
View Full Code Here

TOP

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

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.