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

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


                          + " Unknown consumer " + cids[i]);
                } else if (c.getConsumerUID().getBrokerAddress() !=
                           Globals.getClusterBroadcast().getMyAddress())
                {
                     // remote consumer
                     PacketReference ref = Destination.get(ids[i]);
                     ConsumerUID cuid = c.getConsumerUID();
                     // right now we dont store messages for remote
                     // brokers so the sync flag is unnecessary
                     // but who knows if that will change
                     if (ref.acknowledged(cuid, c.getStoredConsumerUID(),
                                          !cuid.isDupsOK(), true, ackack)) {
                           l.add(ref);
                     }

                 } else {
                     logger.log(Logger.INFO,
                         Globals.getBrokerResources().getString(
                         BrokerResources.E_INTERNAL_BROKER_ERROR,
                         "local consumer does not have "
                         + "associated session " + c));
                     throw new BrokerException("Unknown local consumer "
                         + cids[i]);
                }
            } else { // we have a session

               if (fi.FAULT_INJECTION) {
                   PacketReference ref = Destination.get(ids[i]);
                   if (ref != null && !ref.getDestination().isAdmin() && !ref.getDestination().isInternal()) {
                       if (fi.checkFault(fi.FAULT_ACK_MSG_1_5, null)) {
                           fi.unsetFault(fi.FAULT_ACK_MSG_1_5);
                           BrokerException bex = new BrokerException("FAULT:"+fi.FAULT_ACK_MSG_1_5, Status.GONE);
                           bex.setRemoteConsumerUIDs(String.valueOf(cids[i].longValue()));
                           bex.setRemote(true);
                           throw bex;
                       }
                   }
               }
               PacketReference ref = s.ackMessage(cids[i], ids[i], ackack);
               if (ref != null) {
                     l.add(ref);
               }
            }
        }
View Full Code Here


                    logger.log(Logger.WARNING, Globals.getBrokerResources().getKString(
                                      BrokerResources.W_UPDATE_TRAN_STATE_FAIL, args));
                    }
                }
                if (ex instanceof TransactionAckExistException) {
                    PacketReference ref = Destination.get(ids[i]);
                    if (ref != null && (ref.isOverrided() || ref.isOverriding())) {
                        ((BrokerException)ex).overrideStatusCode(Status.GONE);
                        ((BrokerException)ex).setRemoteConsumerUIDs(
                                 String.valueOf(cids[i].longValue()));
                        ((BrokerException)ex).setRemote(true);
                        consumer.recreationRequested();
View Full Code Here

                if (c == null) { // unknown consumer
                    throw new BrokerException("Internal Error, " +
                       "unknown consumer " + cids[i],
                       Status.BAD_REQUEST);
                }
                PacketReference ref = Destination.get(ids[i]);
                if (ref == null) {
                    logger.log(Logger.DEBUG, "in validateMessages: Could not find " + ids[i]);
                    continue;
                }
                if (!ref.hasConsumerAcked(c.getStoredConsumerUID())) {
                    return false;
                }
           }
        }
        
View Full Code Here

            if (DEBUG) {
            logger.log(logger.INFO, "handleDead["+i+", "+ids.length+"]:sysid="+
                                    ids[i]+", cid="+cids[i]+", on connection "+con);
            }

            PacketReference ref = s.handleDead(cids[i], ids[i], deadReason,
                                               thr, comment, deliverCnt);

            // if we return the reference, we could not re-deliver it ...
            // no consumers .. so clean it up
            if (ref != null) {
View Full Code Here

            }
            if (DEBUG) {
            logger.log(logger.INFO, "handleUndeliverable["+i+", "+ids.length+"]:sysid="+
                                    ids[i]+", cid="+cids[i]+", on connection "+con);
            }
            PacketReference ref = (s == null ? null : s.handleUndeliverable(cids[i], ids[i]));

            // if we return the reference, we could not re-deliver it ...
            // no consumers .. so clean it up
            if (ref != null) {
                l.add(ref);
View Full Code Here

    {
        ArrayList returnlist = new ArrayList();
        Iterator itr = ids.iterator();
        while (itr.hasNext()) {
            SysMessageID id = (SysMessageID)itr.next();
            PacketReference ref = Destination.get(id);
            if (ref == null) continue;
            Packet realp = ref.getPacket();
            if (ref.isInvalid()) continue;
            Packet p = new Packet(false /* use direct buffers */);
            p.fill(realp);
            p.setConsumerID(cid);
            returnlist.add(p);
        }
View Full Code Here

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

      {
          DataHandler handler = (DataHandler)
                      pr.getHandler(PacketType.MESSAGE);

          Destination d = null;
          PacketReference ref = null;
          Set s = null;
          boolean route = false;
          boolean isadmin = con.isAdminConnection();
          try {
               d = Destination.getDestination(
View Full Code Here

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

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

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

   }

    public HashMap constructMessageInfo(SysMessageID sysMsgID, boolean getBody,
            HashMap destNameType)  {
        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;
        int typeMask = DestType.DEST_TYPE_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())  {
            typeMask = DestType.DEST_TYPE_QUEUE;
  } else  {
            typeMask = DestType.DEST_TYPE_TOPIC;
  }

        h.put("DestinationType", new Integer(typeMask));

        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;
                        logger.log(Logger.WARNING, 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";
                    logger.log(Logger.WARNING, errMsg, e);
          }
      }

            h.put("ReplyToDestinationName", replyToDestName);
      if (destFound)  {
    if (isQueue)  {
                    typeMask = DestType.DEST_TYPE_QUEUE;
    } else  {
                    typeMask = DestType.DEST_TYPE_TOPIC;
    }
                h.put("ReplyToDestinationType", new Integer(typeMask));
      }
        }

        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

TOP

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

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.