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

Examples of com.sun.messaging.jmq.jmsserver.core.PacketReference$ConsumerMessagePair


        Set set = msgs.getAll(f);
        msgs.removeAll(set, cleanupReason);
        Iterator itr = set.iterator();
        while (itr.hasNext()) {
            try {
                PacketReference pr = (PacketReference)itr.next();
                if (pr.acknowledged(getConsumerUID(),
                      getStoredConsumerUID(),
                     !uid.isUnsafeAck(), true))
                {
                     Destination d = Destination.getDestination(pr.getDestinationUID());
                     d.removeMessage(pr.getSysMessageID(), cleanupReason);
                }
            } catch (IOException ex) {
                logger.log(Logger.WARNING,"Internal Error: Problem purging consumer "
                        + this, ex);
            }
View Full Code Here


        // deal w/ remote flow control
        synchronized (remotePendingResumes) {
            if (!remotePendingResumes.isEmpty()) {
               Iterator itr = remotePendingResumes.iterator();
               while (itr.hasNext()) {
                   PacketReference ref = (PacketReference)itr.next();
                   //DELIVERED translated to resume flow on remote client
                   try {
                        Globals.getClusterBroadcast().acknowledgeMessage(
                            ref.getAddress(), ref.getSysMessageID(),
                            uid, ClusterBroadcast.MSG_DELIVERED, null, false);
                   } catch (BrokerException ex) {
                        logger.log(Logger.DEBUG,"Can not send DELIVERED ack "
                             + " received ", ex);
                   }
View Full Code Here

               int myprefetch = prefetchVal;
               int totalPrefetched = 0;
               BrokerAddress addr = null;
               ArrayList addrs = new ArrayList();
               Destination d = null;
               PacketReference ref = null;
               HashMap props = null;
               long systemrm = -1, destrm = -1, room = -1;
               Iterator itr = remotePendingResumes.iterator();
               while (itr.hasNext()) {
                   ref = (PacketReference)itr.next();
                   addr = ref.getAddress();
                   if (addrs.contains(addr)) {
                       itr.remove();
                       continue;
                   }
                   myprefetch = prefetchVal;
                   systemrm = destrm = room = -1;
                   props = new HashMap();
                   d = Destination.findDestination(ref.getDestinationUID());
                   try {
                       systemrm = Destination.checkSystemLimit(ref);
                   } catch (Throwable t) {
                       systemrm = 0;
                   }
                   if (d != null) {
                       destrm = d.checkDestinationCapacity(ref);
                   }
                   if (systemrm >= 0 && destrm >= 0) {
                       room = Math.min(systemrm, destrm);
                   } else if(systemrm >= 0) {
                       room = systemrm;
                   } else {
                       room = destrm;
                   }
                   if (room == 0) {
                       room = 1;
                   }
                   myprefetch = prefetchVal;
                   if (room > 0) {
                       myprefetch = (int)(room - totalPrefetched);
                       if (myprefetch <= 0) {
                           myprefetch = 1;
                       } else {
                           int ret = checkIfMsgsInRateGTOutRate(d);
                           if (ret == 0) {
                               myprefetch = 1;
                           } else if (ret == 1) {
                               myprefetch = 1;
                           }
                       }
                       if (prefetchVal > 0) {
                           myprefetch =  Math.min(prefetchVal, myprefetch);
                           if (myprefetch <= 0) {
                               myprefetch = 1;
                           }
                       }
                   }
                   //DELIVERED translated to resume flow on remote client
                   try {
                        props.put(Consumer.PREFETCH, new Integer(myprefetch));
                        Globals.getClusterBroadcast().acknowledgeMessage(
                            addr, ref.getSysMessageID(),
                            uid, ClusterBroadcast.MSG_DELIVERED, props, false);
                        if (addr != null) {
                            addrs.add(addr);
                        }
                        totalPrefetched += myprefetch;
View Full Code Here

        synchronized(remotePendingResumes) {
            vals = new ArrayList(remotePendingResumes);
        }
        Iterator itr = vals.iterator();
        while (itr.hasNext()) {
            PacketReference ref = (PacketReference)itr.next();
            String val = ref.getAddress()+": "+ref;
            v1.add(val);
        }
        ht.put("remotePendingResumes", v1);
        Vector v2 = new Vector();
        synchronized(lastDestMetrics) {
View Full Code Here

    public Vector getDebugMessages(boolean full) {
        Vector ht = new Vector();
        synchronized(msgs) {
            Iterator itr = msgs.iterator();
            while (itr.hasNext()) {
                PacketReference pr = (PacketReference)itr.next();
                ht.add( (full ? pr.getPacket().dumpPacketString() :
                     pr.getPacket().toString()));
            }
        }
        return ht;
      
    }
View Full Code Here

                assert r != RemoveReason.DELIVERED;
                assert r != RemoveReason.ACKNOWLEDGED;
                assert r != RemoveReason.ROLLBACK;
                assert r != RemoveReason.OVERFLOW;
                assert r != RemoveReason.ERROR;
                PacketReference ref = (PacketReference)oldval;
                msgs.remove(ref);
            }
View Full Code Here

      if (messageID != null)  {
    d.load();

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

    if (pr != null)  {
        HashMap h = constructMessageInfo(sysMsgID,
            getBody.booleanValue(),
            destNameType);
View Full Code Here

    }

    private HashMap constructMessageInfo(SysMessageID sysMsgID, boolean getBody,
        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))  {
                        errMsg = "Cannot determine type of ReplyTo destination."
          + " There is a topic and queue with the name: "
          + replyToDestName;
      throw new BrokerException(errMsg);
        } else if (queue != null)  {
            destFound = true;
            isQueue = true;
        } else if (topic != null)  {
            destFound = true;
            isQueue = false;
        }

        if (destFound)  {
            /*
             * Cache dest name/type so that we can look it up there
             * next time.
             */
            destNameType.put(replyToDestName, new Boolean(isQueue));
        } else  {
            /*
             * It is possible that this destination no longer exists.
             * e.g. Temporary destination, whose connection has gone away.
             * Not sure how to proceed at this point.
             */
        }
          } catch (Exception e)  {
                    errMsg = "Caught exception while determining ReplyTo destination type";
        throw new BrokerException(errMsg);
          }
      }

            h.put("ReplyToDestinationName", replyToDestName);
      if (destFound)  {
    if (isQueue)  {
                    destType = DestinationType.QUEUE;
    } else  {
                    destType = DestinationType.TOPIC;
    }
                h.put("ReplyToDestinationType", destType);
      }
        }

        h.put("Timestamp", new Long(pkt.getTimestamp()));

        h.put("Type", pkt.getMessageType());

        Hashtable msgProps;

        try  {
            msgProps = pr.getProperties();
        } catch (Exception e)  {
            msgProps = null;
        }
        h.put("MessageProperties", msgProps);

        int packetType = pr.getPacket().getPacketType();
        h.put("MessageBodyType", new Integer(packetType));

        if (getBody)  {
            ByteBuffer bb = pr.getPacket().getMessageBodyByteBuffer();
            byte[] msgBody = null;

            if (bb.hasArray())  {
                msgBody = bb.array();
            }
View Full Code Here

                    }

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

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

TOP

Related Classes of com.sun.messaging.jmq.jmsserver.core.PacketReference$ConsumerMessagePair

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.