Search in sources :

Example 21 with ClientFuture

use of org.apache.activemq.transport.amqp.client.util.ClientFuture in project activemq-artemis by apache.

the class AmqpSession method close.

/**
 * Close the receiver, a closed receiver will throw exceptions if any further send
 * calls are made.
 *
 * @throws IOException if an error occurs while closing the receiver.
 */
public void close() throws IOException {
    if (closed.compareAndSet(false, true)) {
        final ClientFuture request = new ClientFuture();
        getScheduler().execute(new Runnable() {

            @Override
            public void run() {
                checkClosed();
                close(request);
                pumpToProtonTransport(request);
            }
        });
        request.sync();
    }
}
Also used : ClientFuture(org.apache.activemq.transport.amqp.client.util.ClientFuture)

Example 22 with ClientFuture

use of org.apache.activemq.transport.amqp.client.util.ClientFuture in project activemq-artemis by apache.

the class AmqpSession method createMulticastReceiver.

/**
 * Create a receiver instance using the given Source
 *
 * @param source the caller created and configured Source used to create the receiver link.
 * @return a newly created receiver that is ready for use.
 * @throws Exception if an error occurs while creating the receiver.
 */
public AmqpReceiver createMulticastReceiver(Source source, String receiverId, String receiveName) throws Exception {
    checkClosed();
    final ClientFuture request = new ClientFuture();
    final AmqpReceiver receiver = new AmqpReceiver(AmqpSession.this, source, receiverId);
    receiver.setSubscriptionName(receiveName);
    connection.getScheduler().execute(new Runnable() {

        @Override
        public void run() {
            checkClosed();
            receiver.setStateInspector(getStateInspector());
            receiver.open(request);
            pumpToProtonTransport(request);
        }
    });
    request.sync();
    return receiver;
}
Also used : ClientFuture(org.apache.activemq.transport.amqp.client.util.ClientFuture)

Example 23 with ClientFuture

use of org.apache.activemq.transport.amqp.client.util.ClientFuture in project activemq-artemis by apache.

the class AmqpSession method createReceiver.

/**
 * Create a receiver instance using the given Source
 *
 * @param source the caller created and configured Source used to create the receiver link.
 * @param receiverId the receiver id to use.
 * @return a newly created receiver that is ready for use.
 * @throws Exception if an error occurs while creating the receiver.
 */
public AmqpReceiver createReceiver(Source source, String receiverId) throws Exception {
    checkClosed();
    final ClientFuture request = new ClientFuture();
    final AmqpReceiver receiver = new AmqpReceiver(AmqpSession.this, source, receiverId);
    connection.getScheduler().execute(new Runnable() {

        @Override
        public void run() {
            checkClosed();
            receiver.setStateInspector(getStateInspector());
            receiver.open(request);
            pumpToProtonTransport(request);
        }
    });
    request.sync();
    return receiver;
}
Also used : ClientFuture(org.apache.activemq.transport.amqp.client.util.ClientFuture)

Example 24 with ClientFuture

use of org.apache.activemq.transport.amqp.client.util.ClientFuture in project activemq-artemis by apache.

the class AmqpSession method createMulticastReceiver.

/**
 * Create a receiver instance using the given Source
 *
 * @param source the caller created and configured Source used to create the receiver link.
 * @return a newly created receiver that is ready for use.
 * @throws Exception if an error occurs while creating the receiver.
 */
public AmqpReceiver createMulticastReceiver(String receiverId, String address, String receiveName) throws Exception {
    checkClosed();
    final ClientFuture request = new ClientFuture();
    final AmqpReceiver receiver = new AmqpReceiver(AmqpSession.this, address, receiverId);
    receiver.setSubscriptionName(receiveName);
    connection.getScheduler().execute(new Runnable() {

        @Override
        public void run() {
            checkClosed();
            receiver.setStateInspector(getStateInspector());
            receiver.open(request);
            pumpToProtonTransport(request);
        }
    });
    request.sync();
    return receiver;
}
Also used : ClientFuture(org.apache.activemq.transport.amqp.client.util.ClientFuture)

Example 25 with ClientFuture

use of org.apache.activemq.transport.amqp.client.util.ClientFuture in project activemq-artemis by apache.

the class AmqpSession method createReceiver.

/**
 * Create a receiver instance using the given address
 *
 * @param address   the address to which the receiver will subscribe for its messages.
 * @param selector  the JMS selector to use for the subscription
 * @param noLocal   should the subscription have messages from its connection filtered.
 * @param presettle should the receiver be created with a settled sender mode.
 * @return a newly created receiver that is ready for use.
 * @throws Exception if an error occurs while creating the receiver.
 */
public AmqpReceiver createReceiver(String address, String selector, boolean noLocal, boolean presettle) throws Exception {
    checkClosed();
    final ClientFuture request = new ClientFuture();
    final AmqpReceiver receiver = new AmqpReceiver(AmqpSession.this, address, getNextReceiverId());
    receiver.setNoLocal(noLocal);
    receiver.setPresettle(presettle);
    if (selector != null && !selector.isEmpty()) {
        receiver.setSelector(selector);
    }
    connection.getScheduler().execute(new Runnable() {

        @Override
        public void run() {
            checkClosed();
            receiver.setStateInspector(getStateInspector());
            receiver.open(request);
            pumpToProtonTransport(request);
        }
    });
    request.sync();
    return receiver;
}
Also used : ClientFuture(org.apache.activemq.transport.amqp.client.util.ClientFuture)

Aggregations

ClientFuture (org.apache.activemq.transport.amqp.client.util.ClientFuture)30 IOException (java.io.IOException)15 InvalidDestinationException (javax.jms.InvalidDestinationException)9 JmsOperationTimedOutException (org.apache.qpid.jms.JmsOperationTimedOutException)8 InactivityIOException (org.apache.activemq.transport.InactivityIOException)3 ClientFutureSynchronization (org.apache.activemq.transport.amqp.client.util.ClientFutureSynchronization)3 SaslAuthenticator (org.apache.activemq.transport.amqp.client.sasl.SaslAuthenticator)1 AsyncResult (org.apache.activemq.transport.amqp.client.util.AsyncResult)1 Binary (org.apache.qpid.proton.amqp.Binary)1 Modified (org.apache.qpid.proton.amqp.messaging.Modified)1 Rejected (org.apache.qpid.proton.amqp.messaging.Rejected)1 TransactionalState (org.apache.qpid.proton.amqp.transaction.TransactionalState)1 Sasl (org.apache.qpid.proton.engine.Sasl)1