Package org.apache.qpid.proton.engine

Examples of org.apache.qpid.proton.engine.Session


            protonConnection.open();
            write();
         }

         //handle any new sessions
         Session session = protonConnection.sessionHead(ProtonProtocolManager.UNINITIALIZED, ProtonProtocolManager.INITIALIZED);
         while (session != null)
         {
            try
            {
               ProtonSession protonSession = getSession(session);
               session.setContext(protonSession);
               session.open();

            }
            catch (HornetQAMQPException e)
            {
               protonConnection.setCondition(new ErrorCondition(e.getAmqpError(), e.getMessage()));
               session.close();
            }
            write();
            session = protonConnection.sessionHead(ProtonProtocolManager.UNINITIALIZED, ProtonProtocolManager.INITIALIZED);
         }

         //handle new link (producer or consumer
         LinkImpl link = (LinkImpl) protonConnection.linkHead(ProtonProtocolManager.UNINITIALIZED, ProtonProtocolManager.INITIALIZED);
         while (link != null)
         {
            try
            {
               protonProtocolManager.handleNewLink(link, getSession(link.getSession()));
            }
            catch (HornetQAMQPException e)
            {
               link.setCondition(new ErrorCondition(e.getAmqpError(), e.getMessage()));
               link.close();
            }
            link = (LinkImpl) protonConnection.linkHead(ProtonProtocolManager.UNINITIALIZED, ProtonProtocolManager.INITIALIZED);
         }

         //handle any deliveries
         DeliveryImpl delivery;

         Iterator<DeliveryImpl> iterator = protonConnection.getWorkSequence();

         while (iterator.hasNext())
         {
            delivery = iterator.next();
            ProtonDeliveryHandler handler = (ProtonDeliveryHandler) delivery.getLink().getContext();
            try
            {
               handler.onMessage(delivery);
            }
            catch (HornetQAMQPException e)
            {
               delivery.getLink().setCondition(new ErrorCondition(e.getAmqpError(), e.getMessage()));
            }
         }

         link = (LinkImpl) protonConnection.linkHead(ProtonProtocolManager.ACTIVE, ProtonProtocolManager.ANY_ENDPOINT_STATE);
         while (link != null)
         {
            try
            {
               protonProtocolManager.handleActiveLink(link);
            }
            catch (HornetQAMQPException e)
            {
               link.setCondition(new ErrorCondition(e.getAmqpError(), e.getMessage()));
            }
            link = (LinkImpl) link.next(ProtonProtocolManager.ACTIVE, ProtonProtocolManager.ANY_ENDPOINT_STATE);
         }

         link = (LinkImpl) protonConnection.linkHead(ProtonProtocolManager.ACTIVE, ProtonProtocolManager.CLOSED);
         while (link != null)
         {
            try
            {
               ((ProtonDeliveryHandler) link.getContext()).close();
            }
            catch (HornetQAMQPException e)
            {
               link.setCondition(new ErrorCondition(e.getAmqpError(), e.getMessage()));
            }
            link.close();

            link = (LinkImpl) link.next(ProtonProtocolManager.ACTIVE, ProtonProtocolManager.CLOSED);
         }

         session = protonConnection.sessionHead(ProtonProtocolManager.ACTIVE, ProtonProtocolManager.CLOSED);
         while (session != null)
         {
            ProtonSession protonSession = (ProtonSession) session.getContext();
            protonSession.close();
            sessions.remove(session);
            session.close();
            session = session.next(ProtonProtocolManager.ACTIVE, ProtonProtocolManager.CLOSED);
         }

         if (protonConnection.getLocalState() == EndpointState.ACTIVE && protonConnection.getRemoteState() == EndpointState.CLOSED)
         {
            for (ProtonSession protonSession : sessions.values())
View Full Code Here


         protonConnection.open();
         write();
      }

      //handle any new sessions
      Session session = protonConnection.sessionHead(ProtonProtocolManager.UNINITIALIZED, ProtonProtocolManager.INITIALIZED);
      while (session != null)
      {
         try
         {
            ProtonSession protonSession = getSession(session);
            session.setContext(protonSession);
            session.open();

         }
         catch (HornetQAMQPException e)
         {
            protonConnection.setLocalError(new EndpointError(e.getClass().getName(), e.getMessage()));
            session.close();
         }
         write();
         session = protonConnection.sessionHead(ProtonProtocolManager.UNINITIALIZED, ProtonProtocolManager.INITIALIZED);
      }

      //handle new link (producer or consumer
      LinkImpl link = (LinkImpl) protonConnection.linkHead(ProtonProtocolManager.UNINITIALIZED, ProtonProtocolManager.INITIALIZED);
      while (link != null)
      {
         try
         {
            protonProtocolManager.handleNewLink(link, getSession(link.getSession()));
         }
         catch (HornetQAMQPException e)
         {
            link.setLocalError(new EndpointError(e.getAmqpError(), e.getMessage()));
            link.close();
         }
         link = (LinkImpl) protonConnection.linkHead(ProtonProtocolManager.UNINITIALIZED, ProtonProtocolManager.INITIALIZED);
      }

      //handle any deliveries
      DeliveryImpl delivery;

      Iterator<DeliveryImpl> iterator = protonConnection.getWorkSequence();

      while (iterator.hasNext())
      {
         delivery = iterator.next();
         ProtonDeliveryHandler handler = (ProtonDeliveryHandler) delivery.getLink().getContext();
         try
         {
            handler.onMessage(delivery);
         }
         catch (HornetQAMQPException e)
         {
            delivery.getLink().setLocalError(new EndpointError(e.getAmqpError(), e.getMessage()));
         }
      }

      link = (LinkImpl) protonConnection.linkHead(ProtonProtocolManager.ACTIVE, ProtonProtocolManager.ANY_ENDPOINT_STATE);
      while (link != null)
      {
         try
         {
            protonProtocolManager.handleActiveLink(link);
         }
         catch (HornetQAMQPException e)
         {
            link.setLocalError(new EndpointError(e.getAmqpError(), e.getMessage()));
         }
         link = (LinkImpl) link.next(ProtonProtocolManager.ACTIVE, ProtonProtocolManager.ANY_ENDPOINT_STATE);
      }

      link = (LinkImpl) protonConnection.linkHead(ProtonProtocolManager.ACTIVE, ProtonProtocolManager.CLOSED);
      while (link != null)
      {
         try
         {
            ((ProtonDeliveryHandler) link.getContext()).close();
         }
         catch (HornetQAMQPException e)
         {
            link.setLocalError(new EndpointError(e.getAmqpError(), e.getMessage()));
         }
         link.close();

         link = (LinkImpl) link.next(ProtonProtocolManager.ACTIVE, ProtonProtocolManager.CLOSED);
      }

      session = protonConnection.sessionHead(ProtonProtocolManager.ACTIVE, ProtonProtocolManager.CLOSED);
      while (session != null)
      {
         ProtonSession protonSession = (ProtonSession) session.getContext();
         protonSession.close();
         sessions.remove(session);
         session.close();
         session = session.next(ProtonProtocolManager.ACTIVE, ProtonProtocolManager.CLOSED);
      }

      if (protonConnection.getLocalState() == EndpointState.ACTIVE && protonConnection.getRemoteState() == EndpointState.CLOSED)
      {
         for (ProtonSession protonSession : sessions.values())
View Full Code Here

        for (Link link : new Links(connection, ACTIVE, ANY))
        {
            C result = finder.test(link);
            if (result != null) return result;
        }
        Session session = connection.session();
        session.open();
        C link = finder.create(session);
        linkAdded(link);
        link.open();
        return link;
    }
View Full Code Here

        queue.execute(new Task() {
            public void run() {
                try {
                    System.out.println("Creating a client connection.");
                    AmqpConnection c = startClient(address);
                    Session session = c.getProtonConnection().session();
                    session.open();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
View Full Code Here

    {
    }

    private void assertConnectionIsUsable()
    {
        Session clientSesion = _clientConnection.session();
        clientSesion.open();
        _pumper.pumpAll();

        Session serverSession = _serverConnection.sessionHead(of(UNINITIALIZED), of(ACTIVE));
        serverSession.open();
        _pumper.pumpAll();

        assertEnpointState(clientSesion, ACTIVE, ACTIVE);
        assertEnpointState(serverSession, ACTIVE, ACTIVE);
    }
View Full Code Here

        for (Link link : new Links(connection, ACTIVE, ANY))
        {
            C result = finder.test(link);
            if (result != null) return result;
        }
        Session session = connection.session();
        session.open();
        C link = finder.create(session);
        link.open();
        return link;
    }
View Full Code Here

                if (protonConnection.getLocalState() == EndpointState.UNINITIALIZED && protonConnection.getRemoteState() != EndpointState.UNINITIALIZED) {
                    onConnectionOpen();
                }

                // Lets map amqp sessions to openwire sessions..
                Session session = protonConnection.sessionHead(UNINITIALIZED_SET, INITIALIZED_SET);
                while (session != null) {
                    onSessionOpen(session);
                    session = protonConnection.sessionHead(UNINITIALIZED_SET, INITIALIZED_SET);
                }

                Link link = protonConnection.linkHead(UNINITIALIZED_SET, INITIALIZED_SET);
                while (link != null) {
                    onLinkOpen(link);
                    link = protonConnection.linkHead(UNINITIALIZED_SET, INITIALIZED_SET);
                }

                Delivery delivery = protonConnection.getWorkHead();
                while (delivery != null) {
                    AmqpDeliveryListener listener = (AmqpDeliveryListener) delivery.getLink().getContext();
                    if (listener != null) {
                        listener.onDelivery(delivery);
                    }
                    delivery = delivery.getWorkNext();
                }

                link = protonConnection.linkHead(ACTIVE_STATE, CLOSED_STATE);
                while (link != null) {
                    ((AmqpDeliveryListener) link.getContext()).onClose();
                    link.close();
                    link = link.next(ACTIVE_STATE, CLOSED_STATE);
                }

                link = protonConnection.linkHead(ACTIVE_STATE, ALL_STATES);
                while (link != null) {
                    ((AmqpDeliveryListener) link.getContext()).drainCheck();
                    link = link.next(ACTIVE_STATE, ALL_STATES);
                }

                session = protonConnection.sessionHead(ACTIVE_STATE, CLOSED_STATE);
                while (session != null) {
                    // TODO - close links?
                    onSessionClose(session);
                    session = session.next(ACTIVE_STATE, CLOSED_STATE);
                }
                if (protonConnection.getLocalState() == EndpointState.ACTIVE && protonConnection.getRemoteState() == EndpointState.CLOSED) {
                    doClose();
                }
View Full Code Here

                if (protonConnection.getLocalState() == EndpointState.UNINITIALIZED && protonConnection.getRemoteState() != EndpointState.UNINITIALIZED) {
                    onConnectionOpen();
                }

                // Lets map amqp sessions to openwire sessions..
                Session session = protonConnection.sessionHead(UNINITIALIZED_SET, INITIALIZED_SET);
                while (session != null) {
                    onSessionOpen(session);
                    session = protonConnection.sessionHead(UNINITIALIZED_SET, INITIALIZED_SET);
                }

                Link link = protonConnection.linkHead(UNINITIALIZED_SET, INITIALIZED_SET);
                while (link != null) {
                    onLinkOpen(link);
                    link = protonConnection.linkHead(UNINITIALIZED_SET, INITIALIZED_SET);
                }

                Delivery delivery = protonConnection.getWorkHead();
                while (delivery != null) {
                    AmqpDeliveryListener listener = (AmqpDeliveryListener) delivery.getLink().getContext();
                    if (listener != null) {
                        listener.onDelivery(delivery);
                    }
                    delivery = delivery.getWorkNext();
                }

                link = protonConnection.linkHead(ACTIVE_STATE, CLOSED_STATE);
                while (link != null) {
                    ((AmqpDeliveryListener) link.getContext()).onClose();
                    link.close();
                    link = link.next(ACTIVE_STATE, CLOSED_STATE);
                }

                link = protonConnection.linkHead(ACTIVE_STATE, ALL_STATES);
                while (link != null) {
                    ((AmqpDeliveryListener) link.getContext()).drainCheck();
                    link = link.next(ACTIVE_STATE, ALL_STATES);
                }

                session = protonConnection.sessionHead(ACTIVE_STATE, CLOSED_STATE);
                while (session != null) {
                    // TODO - close links?
                    onSessionClose(session);
                    session = session.next(ACTIVE_STATE, CLOSED_STATE);
                }
                if (protonConnection.getLocalState() == EndpointState.ACTIVE && protonConnection.getRemoteState() == EndpointState.CLOSED) {
                    doClose();
                }
View Full Code Here

        for (Link link : new Links(connection, ACTIVE, ANY))
        {
            C result = finder.test(link);
            if (result != null) return result;
        }
        Session session = connection.session();
        session.open();
        C link = finder.create(session);
        link.open();
        return link;
    }
View Full Code Here

        for (Link link : new Links(connection, ACTIVE, ANY))
        {
            C result = finder.test(link);
            if (result != null) return result;
        }
        Session session = connection.session();
        session.open();
        C link = finder.create(session);
        linkAdded(link);
        link.open();
        return link;
    }
View Full Code Here

TOP

Related Classes of org.apache.qpid.proton.engine.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.