Search in sources :

Example 1 with ProtonClientSenderContext

use of org.apache.activemq.artemis.protocol.amqp.client.ProtonClientSenderContext in project activemq-artemis by apache.

the class AMQPSessionContext method addSender.

public void addSender(Sender sender) throws Exception {
    // TODO: Remove this check when we have support for global link names
    boolean outgoing = (sender.getContext() != null && sender.getContext().equals(true));
    ProtonServerSenderContext protonSender = outgoing ? new ProtonClientSenderContext(connection, sender, this, sessionSPI) : new ProtonServerSenderContext(connection, sender, this, sessionSPI);
    try {
        protonSender.initialise();
        senders.put(sender, protonSender);
        serverSenders.put(protonSender.getBrokerConsumer(), protonSender);
        sender.setContext(protonSender);
        connection.lock();
        try {
            sender.open();
        } finally {
            connection.unlock();
        }
        protonSender.start();
    } catch (ActiveMQAMQPException e) {
        senders.remove(sender);
        sender.setSource(null);
        sender.setCondition(new ErrorCondition(e.getAmqpError(), e.getMessage()));
        connection.lock();
        try {
            sender.close();
        } finally {
            connection.unlock();
        }
    }
}
Also used : ErrorCondition(org.apache.qpid.proton.amqp.transport.ErrorCondition) ProtonClientSenderContext(org.apache.activemq.artemis.protocol.amqp.client.ProtonClientSenderContext) ActiveMQAMQPException(org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException)

Aggregations

ProtonClientSenderContext (org.apache.activemq.artemis.protocol.amqp.client.ProtonClientSenderContext)1 ActiveMQAMQPException (org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException)1 ErrorCondition (org.apache.qpid.proton.amqp.transport.ErrorCondition)1