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

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


                            getUser(cid),
                            getWildcard(cid),
                            getNextMessageID(cid)
      };
  CompositeData cd = null;
        Consumer con = Consumer.getConsumer(cid);

        if (monitorCompType == null)  {
            monitorCompType = new CompositeType("ConsumerMonitorInfo", "ConsumerMonitorInfo",
                        consumerInfoMonitorItemNames, consumerInfoMonitorItemDesc,
        consumerInfoMonitorItemTypes);
View Full Code Here


                    remoteConsumerUIDs.append(" ");
                    String cidstr = null;
                    ArrayList remoteConsumerUIDa = new ArrayList();
                    for (int i = 0; i < ids.length; i++) {
                        PacketReference ref = Destination.get(ids[i]);
                        Consumer c = Consumer.getConsumer(cids[i]);
                        if (c == null) continue;
                        ConsumerUID sid = c.getStoredConsumerUID();
                        if (sid == null || sid.equals(cids[i])) {
                            continue;
                        }
                        BrokerAddress ba = (ref == null ? null: ref.getAddress());
                        BrokerAddress rba = ((BrokerException)thr).getRemoteBrokerAddress();
                        if (c != null && ref != null &&
                            ba != null && rba != null && ba.equals(rba)) {
                            cidstr = String.valueOf(c.getConsumerUID().longValue());
                            if (!remoteConsumerUIDa.contains(cidstr)) {
                                remoteConsumerUIDa.add(cidstr);
                                remoteConsumerUIDs.append(cidstr);
                                remoteConsumerUIDs.append(" ");
                            }
View Full Code Here

            logger.log(logger.INFO, "handleAcks["+i+", "+ids.length+"]:sysid="+
                                     ids[i]+", cid="+cids[i]+", on connection "+con);
            }
            Session s = Session.getSession(cids[i]);
            if (s == null) { // consumer does not have session
               Consumer c = Consumer.getConsumer(cids[i]);
               if (c == null) {
                   if (!con.isValid() || con.isBeingDestroyed()) {
                        logger.log(logger.DEBUG,"Received ack for consumer "
                             + cids[i] " on closing connection " + con);
                        continue;
                   }
                   if (BrokerStateHandler.shutdownStarted)
                       throw new BrokerException(
                           BrokerResources.I_ACK_FAILED_BROKER_SHUTDOWN);
                   throw new BrokerException("Internal Error: Unable to complete processing acks:"
                          + " 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 {
View Full Code Here

    public List handleTransaction(IMQConnection con, TransactionUID tid,
                                  SysMessageID[] ids, ConsumerUID[] cids)
                                  throws BrokerException {
        for (int i=0; i < ids.length; i ++) {
            Consumer consumer = null;
            try {
                // lookup the session by consumerUID

                Session s = Session.getSession(cids[i]);

                // look up the consumer by consumerUID
                consumer = Consumer.getConsumer(cids[i]);

                if (consumer == null) {
                    throw new BrokerException(
                          Globals.getBrokerResources().getKString(
                          BrokerResources.I_ACK_FAILED_NO_CONSUMER, cids[i]), Status.NOT_FOUND);
                }
                // try and find the stored consumerUID
                ConsumerUID sid = consumer.getStoredConsumerUID();

                // if we still dont have a session, attempt to find one
                if (s == null) {
                    SessionUID suid = consumer.getSessionUID();
                    s = Session.getSession(suid);
                }
                if (s == null)  {
                   if (BrokerStateHandler.shutdownStarted)
                       throw new BrokerException(
                           BrokerResources.I_ACK_FAILED_BROKER_SHUTDOWN);
                   throw new BrokerException("Internal Error: Unable to complete processing transaction:"
                          + " Unknown consumer/session " + cids[i]);
                }
                if (DEBUG) {
                logger.log(logger.INFO, "handleTransaction.addAck["+i+", "+ids.length+"]:tid="+tid+
                           ", sysid="+ids[i]+", cid="+cids[i]+", sid="+sid+" on connection "+con);
                }
                boolean isxa = translist.addAcknowledgement(tid, ids[i], cids[i], sid);
                BrokerAddress addr = s.acknowledgeInTransaction(cids[i], ids[i], tid, isxa);
                if (addr != null && addr != Globals.getMyAddress()) {
                    translist.setAckBrokerAddress(tid, ids[i], cids[i], addr);
                }
                if (fi.FAULT_INJECTION) {
                    if (fi.checkFault(fi.FAULT_TXN_ACK_1_5, null)) {
                        fi.unsetFault(fi.FAULT_TXN_ACK_1_5);
                        TransactionAckExistException tae = new TransactionAckExistException("FAULT:"+fi.FAULT_TXN_ACK_1_5, Status.GONE);
                        tae.setRemoteConsumerUIDs(String.valueOf(cids[i].longValue()));
                        tae.setRemote(true);
                        consumer.recreationRequested();
                        throw tae;
                    }
                }
            } catch (Exception ex) {
                String emsg = "["+ids[i]+", "+cids[i] + "]TUID="+tid;
                if ((ex instanceof BrokerException) &&
                    ((BrokerException)ex).getStatusCode() !=  Status.ERROR) {
                    logger.log(Logger.WARNING , Globals.getBrokerResources().getKString(
                    BrokerResources.E_TRAN_ACK_PROCESSING_FAILED, emsg, ex.getMessage()), ex);
                } else {
                    logger.log(Logger.ERROR , Globals.getBrokerResources().getKString(
                    BrokerResources.E_TRAN_ACK_PROCESSING_FAILED, emsg, ex.getMessage()), ex);
                }
                int state = -1;
                JMQXid xid = null;
                try {
                    TransactionState ts = translist.retrieveState(tid);
                    if (ts != null) {
                        state = ts.getState();
                        xid = ts.getXid();
                    }
                    translist.updateState(tid, TransactionState.FAILED, true);
                } catch (Exception e) {
                    if (!(e instanceof UnknownTransactionException)) {
                    String args[] = { TransactionState.toString(state),
                                      TransactionState.toString(TransactionState.FAILED),
                                      tid.toString()(xid == null ? "null": xid.toString()) };
                    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();
                    }
                }
                if (ex instanceof BrokerExceptionthrow (BrokerException)ex;

                throw new BrokerException("Internal Error: Unable to " +
View Full Code Here

      
        // if transaction exists we need to check its information
        if (openTransaction) {
            for (int i=0; i < ids.length; i ++) {
                Consumer c = Consumer.getConsumer(cids[i]);
                if (c == null) { // unknown consumer
                    throw new BrokerException("Internal Error, " +
                       "unknown consumer " + cids[i],
                       Status.BAD_REQUEST);
                }
                if (!translist.checkAcknowledgement(tid, ids[i],
                   c.getConsumerUID())) {
                    return false;
                }
           }
        } else { // check packet reference
            for (int i=0; i < ids.length; i ++) {
                Consumer c = Consumer.getConsumer(cids[i]);
                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

            props = new Hashtable();
          }

          Integer bufsize = null;

          Consumer consumer = null;
          if (props != null) {
              bufsize = (Integer)props.get("JMQSize");
              if (bufsize == null) { // try old protocol
                  bufsize = (Integer)props.get("JMQRBufferSize");
              }
View Full Code Here

    if (d != null) {
              Iterator cons = d.getConsumers();

              while (cons.hasNext())  {
            Consumer oneCon = (Consumer)cons.next();

                        HashMap h = constructConsumerInfo(oneCon.getConsumerUID(), d);

            v.add(h);
              }
          } else  {
                    errMsg= rb.getString(rb.X_DESTINATION_NOT_FOUND,
View Full Code Here

   */
        return (new Integer(toExternalAckMode(cid.getAckType())));
    }

    private static String getClientID(ConsumerUID cid)  {
  Consumer con = Consumer.getConsumer(cid);

  if (con == null)  {
      return (null);
  }

        return (con.getClientID());
    }
View Full Code Here

  return(Long.toString(cxnId.longValue()));
    }

    public static boolean isDurable(ConsumerUID cid)  {
  Consumer con = Consumer.getConsumer(cid);

  if (con != null)  {
      return (con.isDurableSubscriber());
  }

  return (false);
    }
View Full Code Here

    public static boolean isDurableActive(ConsumerUID cid)  {
  if (!isDurable(cid))  {
      return (false);
  }

  Consumer con = Consumer.getConsumer(cid);

  if (con != null)  {
      return (con.isActive());
  }

  return (false);

    }
View Full Code Here

TOP

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

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.