Package org.apache.qpid.proton.engine

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


        {
            if (unsettled != null)
            {
                while (unsettled.hasNext())
                {
                    Delivery d = unsettled.next();
                    if (d == null)
                    {
                        break;
                    }
                    if (d.getRemoteState() != null || d.remotelySettled())
                    {
                        d.settle();
                    }
                    else if (d.getLink().getSession().getConnection().getRemoteState() == EndpointState.CLOSED)
                    {
                        continue;
                    }
                    else
                    {
View Full Code Here


        {
            //do we have at least one message?
            for (Connector<?> c : _driver.connectors())
            {
                Connection connection = c.getConnection();
                Delivery delivery = connection.getWorkHead();
                while (delivery != null)
                {
                    if (delivery.isReadable() && !delivery.isPartial())
                    {
                        return true;
                    }
                    else
                    {
                        delivery = delivery.getWorkNext();
                    }
                }
            }
            return false;
        }
View Full Code Here

            Sender sender = getLink(address.getHost(), port, new SenderFinder(cleanPath(address.getPath())));

            adjustReplyTo(m);

            byte[] tag = String.valueOf(_nextTag++).getBytes();
            Delivery delivery = sender.delivery(tag);
            int encoded;
            while (true)
            {
                try
                {
View Full Code Here

        if (_driver != null) {
            for (Connector<?> c : _driver.connectors())
            {
                Connection connection = c.getConnection();
                _logger.log(Level.FINE, "Attempting to get message from " + connection);
                Delivery delivery = connection.getWorkHead();
                while (delivery != null)
                {
                    if (delivery.isReadable() && !delivery.isPartial())
                    {
                        _logger.log(Level.FINE, "Readable delivery found: " + delivery);
                        int size = read((Receiver) delivery.getLink());
                        Message message = Proton.message();
                        message.decode(_buffer, 0, size);
                        delivery.getLink().advance();
                        _incoming.add(delivery);
                        _distributed--;
                        return message;
                    }
                    else
                    {
                        _logger.log(Level.FINE, "Delivery not readable: " + delivery);
                        delivery = delivery.getWorkNext();
                    }
                }
            }
        }
        return null;
View Full Code Here

        return count;
    }

    private int read(Receiver receiver)
    {
        Delivery dlv = receiver.current();

        if (dlv.isPartial()) {
            throw new IllegalStateException();
        }

        int size = dlv.pending();

        while (_buffer.length < size) {
            _buffer = new byte[_buffer.length * 2];
        }

View Full Code Here

        if (connection.getLocalState() == EndpointState.UNINITIALIZED)
        {
            connection.open();
        }

        Delivery delivery = connection.getWorkHead();
        while (delivery != null)
        {
            if (delivery.getLink() instanceof Sender && delivery.isUpdated())
            {
                delivery.disposition(delivery.getRemoteState());
            }
            //TODO: delivery.clear(); What's the equivalent in java?
            delivery = delivery.getWorkNext();
        }
        _outgoing.slide();

        for (Session session : new Sessions(connection, UNINIT, ANY))
        {
View Full Code Here

        slide();
    }

    Status getStatus(Tracker tracker)
    {
        Delivery delivery = getDelivery(tracker);
        if (delivery != null)
        {
            DeliveryState state = delivery.getRemoteState();
            if (state != null)
            {
                return getStatus(state);
            }
            else if (delivery.remotelySettled() || delivery.isSettled())
            {
                return getStatus(delivery.getLocalState());
            }
            else
            {
                return Status.PENDING;
            }
View Full Code Here

            {
                if (_deliveries.isEmpty())
                {
                    throw new RuntimeException("Inconsistent state, empty delivery queue but lwm=" + _lwm + " and hwm=" + _hwm);
                }
                Delivery d = _deliveries.get(0);
                if (d.getLocalState() == null)
                {
                    d.disposition(ACCEPTED);
                }

                d.settle();
                _deliveries.remove(0);
                _lwm++;
            }
        }
    }
View Full Code Here

        if ((seq - _lwm) < 0 || (seq - _hwm) > 0) return;
        int last = seq - _lwm;
        int start = (flags & Messenger.CUMULATIVE) != 0 ? 0 : last;
        for (int i = start; i <= last && i < _deliveries.size(); ++i)
        {
            Delivery d = _deliveries.get(i);
            if (d != null && !d.isSettled())
            {
                operation.apply(d);
            }
        }
    }
View Full Code Here

        assertEquals(Accepted.getInstance(), _client.delivery.getRemoteState());


        LOGGER.fine(bold("======== About to accept and settle the message on the client"));

        Delivery clientDelivery = _client.connection.getWorkHead();
        assertEquals(_client.delivery, clientDelivery);
        assertTrue(clientDelivery.isUpdated());
        assertEquals(_client.sender, clientDelivery.getLink());
        clientDelivery.disposition(clientDelivery.getRemoteState());
        assertEquals(Accepted.getInstance(), _client.delivery.getLocalState());

        clientDelivery.settle();
        assertNull("Now we've settled, the delivery should no longer be in the work list", _client.connection.getWorkHead());

        pumpClientToServer();


        LOGGER.fine(bold("======== About to settle the message on the server"));

        assertEquals(Accepted.getInstance(), _server.delivery.getRemoteState());
        Delivery serverDelivery = _server.connection.getWorkHead();
        assertEquals(_server.delivery, serverDelivery);
        assertTrue(serverDelivery.isUpdated());
        assertTrue("Client should have already settled", serverDelivery.remotelySettled());
        serverDelivery.settle();
        assertTrue(serverDelivery.isSettled());
        assertNull("Now we've settled, the delivery should no longer be in the work list", _server.connection.getWorkHead());

        // Increment the receiver's credit so its ready for another message.
        // When using proton-c, this call is required in order to generate a Flow frame
        // (proton-j sends one even without it to eagerly restore the session incoming window).
View Full Code Here

TOP

Related Classes of org.apache.qpid.proton.engine.Delivery

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.