Search in sources :

Example 1 with ProtonServerSenderContext

use of org.apache.activemq.artemis.protocol.amqp.proton.ProtonServerSenderContext in project activemq-artemis by apache.

the class AMQPSessionCallback method disconnect.

@Override
public void disconnect(ServerConsumer consumer, SimpleString queueName) {
    ErrorCondition ec = new ErrorCondition(AmqpSupport.RESOURCE_DELETED, "Queue was deleted: " + queueName);
    connection.lock();
    try {
        ((ProtonServerSenderContext) consumer.getProtocolContext()).close(ec);
        connection.flush();
    } catch (ActiveMQAMQPException e) {
        logger.error("Error closing link for " + consumer.getQueue().getAddress());
    } finally {
        connection.unlock();
    }
}
Also used : ErrorCondition(org.apache.qpid.proton.amqp.transport.ErrorCondition) ActiveMQAMQPException(org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException) ProtonServerSenderContext(org.apache.activemq.artemis.protocol.amqp.proton.ProtonServerSenderContext)

Example 2 with ProtonServerSenderContext

use of org.apache.activemq.artemis.protocol.amqp.proton.ProtonServerSenderContext in project activemq-artemis by apache.

the class AMQPSessionCallback method onFlowConsumer.

public void onFlowConsumer(Object consumer, int credits, final boolean drain) {
    ServerConsumerImpl serverConsumer = (ServerConsumerImpl) consumer;
    if (drain) {
        // If the draining is already running, then don't do anything
        if (draining.compareAndSet(false, true)) {
            final ProtonServerSenderContext plugSender = (ProtonServerSenderContext) serverConsumer.getProtocolContext();
            serverConsumer.forceDelivery(1, new Runnable() {

                @Override
                public void run() {
                    try {
                        plugSender.reportDrained();
                    } finally {
                        draining.set(false);
                    }
                }
            });
        }
    } else {
        serverConsumer.receiveCredits(-1);
    }
}
Also used : ServerConsumerImpl(org.apache.activemq.artemis.core.server.impl.ServerConsumerImpl) ProtonServerSenderContext(org.apache.activemq.artemis.protocol.amqp.proton.ProtonServerSenderContext)

Aggregations

ProtonServerSenderContext (org.apache.activemq.artemis.protocol.amqp.proton.ProtonServerSenderContext)2 ServerConsumerImpl (org.apache.activemq.artemis.core.server.impl.ServerConsumerImpl)1 ActiveMQAMQPException (org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException)1 ErrorCondition (org.apache.qpid.proton.amqp.transport.ErrorCondition)1