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

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


    public Session createSession(int stype, String creator, IMQConnection con,
            boolean isIndemp)
        throws BrokerException
    {
        Session session = null;
        if (isIndemp) {
            session = Session.getSession(creator);
        }
        if (session == null) {
            session = Session.createSession(con.getConnectionUID(),
                creator);
            session.setAckType(stype);
            con.attachSession(session);
        }
        return session;
     }
View Full Code Here


        boolean isIndemp = msg.getIndempotent();

        try {
            Hashtable props = msg.getProperties();

            Session session = null;
            if (msg.getPacketType() == PacketType.CREATE_SESSION) {
               Integer  ack = (props == null ? null :
                    (Integer)props.get("JMQAckMode"));
               // if we dont know, treat like client ack
               int stype = (ack == null ? Session.NONE
                      : ack.intValue());

               session = createSession(stype, msg.getSysMessageID().toString(),
                    con, isIndemp);
               hash.put("JMQSessionID", new Long(
                    session.getSessionUID().longValue()));

            } else {
                assert msg.getPacketType() == PacketType.DESTROY_SESSION;
                Long lsessionid = (Long)props.get("JMQSessionID");
                if (lsessionid == null) {
View Full Code Here

                }
                return;
            }

            // deal with sessions (the async case)
            Session s = (Session)target;

            // this wakes up the process thread which is blocked on SessionLock
            synchronized (sessionLock) {
                sessionLockNotify = true;
                sessionLock.notify();
View Full Code Here

        for (int i=0; i < ids.length; i ++) {
            if (DEBUG) {
            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 {
                     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

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

        if (deadrs == DEAD_REASON_EXPIRED) {
            deadReason = RemoveReason.EXPIRED_BY_CLIENT;
        }
        List l = new ArrayList();
        for (int i=0; i < ids.length; i ++) {
            Session s = Session.getSession(cids[i]);
            if (s == null) { // consumer does not have session
                 // really nothing to do, ignore
                logger.log(Logger.DEBUG,"Dead message for Unknown Consumer/Session"
                        + cids[i]);
                continue;
            }
            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

                                        SysMessageID[] ids, ConsumerUID[] cids)
                                        throws BrokerException {

        List l = new ArrayList();
        for (int i=0; i < ids.length; i ++) {
            Session s = Session.getSession(cids[i]);
            if (s == null) { // consumer does not have session
                 // really nothing to do, ignore
                logger.log(Logger.DEBUG,"Undeliverable message for Unknown Consumer/Session"
                        + cids[i]);
            }
            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

                    EventType.BUSY_STATE_CHANGED) {
                assert target instanceof Session;
                assert newval instanceof Boolean;
                assert newval != null;
   
                Session s = (Session) target;
   
                synchronized(busySessions) {
                    synchronized (s.getBusyLock()) {
                        if (s.isBusy()) {
                            busySessions.add(s);
                        }
                    }
                }
               
View Full Code Here

      *@param uid session to pause
      */
     public void pauseSession(SessionUID uid)
        throws BrokerException
     {
         Session ses = Session.getSession(uid);
         if (ses == null)
             throw new BrokerException("No session for " + uid);
         ses.pause("PROTOCOL");
     }
View Full Code Here

        }
    }

    private boolean fillNextPacket(Packet p)
    {
        Session s = null;
       
        synchronized(busySessions) {
           Iterator itr = busySessions.iterator();
           while (itr.hasNext()) {
               s = (Session)itr.next();
               itr.remove();
               if (s == null)
                   continue;
               synchronized (s.getBusyLock()) {
                   if (s.isBusy()) {
                       busySessions.add(s);
                       break;
                   }
               }
              
           }
        }

        if (s == null) return false;

        return s.fillNextPacket(p) != null;
    }
View Full Code Here

TOP

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

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.