Class ChannelN

    • Constructor Detail

      • ChannelN

        public ChannelN​(AMQConnection connection,
                        int channelNumber,
                        ConsumerWorkService workService)
        Construct a new channel on the given connection with the given channel number. Usually not called directly - call Connection.createChannel instead.
        Parameters:
        connection - The connection associated with this channel
        channelNumber - The channel number to be associated with this channel
        workService - service for managing this channel's consumer callbacks
        See Also:
        Connection.createChannel()
      • ChannelN

        public ChannelN​(AMQConnection connection,
                        int channelNumber,
                        ConsumerWorkService workService,
                        MetricsCollector metricsCollector)
        Construct a new channel on the given connection with the given channel number. Usually not called directly - call Connection.createChannel instead.
        Parameters:
        connection - The connection associated with this channel
        channelNumber - The channel number to be associated with this channel
        workService - service for managing this channel's consumer callbacks
        metricsCollector - service for managing metrics
        See Also:
        Connection.createChannel()
    • Method Detail

      • removeReturnListener

        public boolean removeReturnListener​(ReturnListener listener)
        Description copied from interface: Channel
        Remove a ReturnListener.
        Specified by:
        removeReturnListener in interface Channel
        Parameters:
        listener - the listener to remove
        Returns:
        true if the listener was found and removed, false otherwise
      • removeFlowListener

        @Deprecated
        public boolean removeFlowListener​(FlowListener listener)
        Deprecated.
        Description copied from interface: Channel
        Remove a FlowListener. Deprecated, superseded by TCP back pressure. Will be removed in next major release.
        Specified by:
        removeFlowListener in interface Channel
        Parameters:
        listener - the listener to remove
        Returns:
        true if the listener was found and removed, false otherwise
        See Also:
        Resource-driven alarms
      • removeConfirmListener

        public boolean removeConfirmListener​(ConfirmListener listener)
        Description copied from interface: Channel
        Remove a ConfirmListener.
        Specified by:
        removeConfirmListener in interface Channel
        Parameters:
        listener - the listener to remove
        Returns:
        true if the listener was found and removed, false otherwise
      • waitForConfirms

        public boolean waitForConfirms()
                                throws InterruptedException
        Wait until all messages published since the last call have been either ack'd or nack'd by the broker. Note, when called on a non-Confirm channel, waitForConfirms throws an IllegalStateException.
        Specified by:
        waitForConfirms in interface Channel
        Returns:
        whether all the messages were ack'd (and none were nack'd)
        Throws:
        InterruptedException
      • waitForConfirms

        public boolean waitForConfirms​(long timeout)
                                throws InterruptedException,
                                       TimeoutException
        Wait until all messages published since the last call have been either ack'd or nack'd by the broker; or until timeout elapses. If the timeout expires a TimeoutException is thrown. When called on a non-Confirm channel, waitForConfirms throws an IllegalStateException.
        Specified by:
        waitForConfirms in interface Channel
        Returns:
        whether all the messages were ack'd (and none were nack'd)
        Throws:
        InterruptedException
        TimeoutException
      • waitForConfirmsOrDie

        public void waitForConfirmsOrDie()
                                  throws IOException,
                                         InterruptedException
        Wait until all messages published since the last call have been either ack'd or nack'd by the broker. If any of the messages were nack'd, waitForConfirmsOrDie will throw an IOException. When called on a non-Confirm channel, it will throw an IllegalStateException.
        Specified by:
        waitForConfirmsOrDie in interface Channel
        Throws:
        IOException
        InterruptedException
      • getDefaultConsumer

        public Consumer getDefaultConsumer()
        Returns the current default consumer.
        Specified by:
        getDefaultConsumer in interface Channel
        Returns:
        an interface to the current default consumer.
      • setDefaultConsumer

        public void setDefaultConsumer​(Consumer consumer)
        Sets the current default consumer. A null argument is interpreted to mean "do not use a default consumer".
        Specified by:
        setDefaultConsumer in interface Channel
        Parameters:
        consumer - the consumer to use, or null indicating "don't use one".
      • processShutdownSignal

        public void processShutdownSignal​(ShutdownSignalException signal,
                                          boolean ignoreClosed,
                                          boolean notifyRpc)
        Protected API - overridden to quiesce consumer work and broadcast the signal to all consumers after calling the superclass's method.
        Overrides:
        processShutdownSignal in class AMQChannel
        Parameters:
        signal - the signal to handle
        ignoreClosed - the flag indicating whether to ignore the AlreadyClosedException thrown when the channel is already closed
        notifyRpc - the flag indicating whether any remaining rpc continuation should be notified with the given signal
      • processAsync

        public boolean processAsync​(Command command)
                             throws IOException
        Protected API - Filters the inbound command stream, processing Basic.Deliver, Basic.Return and Channel.Close specially. If we're in quiescing mode, all inbound commands are ignored, except for Channel.Close and Channel.CloseOk.
        Specified by:
        processAsync in class AMQChannel
        Parameters:
        command - the command to handle asynchronously
        Returns:
        true if we handled the command; otherwise the caller should consider it "unhandled"
        Throws:
        IOException
      • close

        public void close​(int closeCode,
                          String closeMessage)
                   throws IOException,
                          TimeoutException
        Public API - Close this channel.
        Specified by:
        close in interface Channel
        Parameters:
        closeCode - the close code (See under "Reply Codes" in the AMQP specification)
        closeMessage - a message indicating the reason for closing the connection
        Throws:
        IOException - if an error is encountered
        TimeoutException
      • abort

        public void abort()
                   throws IOException
        Public API - Abort this channel with the AMQP.REPLY_SUCCESS close code and message 'OK'. Forces the channel to close and waits for the close operation to complete. Any encountered exceptions in the close operation are silently discarded.
        Specified by:
        abort in interface Channel
        Throws:
        IOException
      • abort

        public void abort​(int closeCode,
                          String closeMessage)
                   throws IOException
        Public API - Abort this channel. Forces the channel to close and waits for the close operation to complete. Any encountered exceptions in the close operation are silently discarded.
        Specified by:
        abort in interface Channel
        Throws:
        IOException
      • close

        protected void close​(int closeCode,
                             String closeMessage,
                             boolean initiatedByApplication,
                             Throwable cause,
                             boolean abort)
                      throws IOException,
                             TimeoutException
        Protected API - Close channel with code and message, indicating the source of the closure and a causing exception (null if none).
        Parameters:
        closeCode - the close code (See under "Reply Codes" in the AMQP specification)
        closeMessage - a message indicating the reason for closing the connection
        initiatedByApplication - true if this comes from an API call, false otherwise
        cause - exception triggering close
        abort - true if we should close and ignore errors
        Throws:
        IOException - if an error is encountered
        TimeoutException
      • basicQos

        public void basicQos​(int prefetchSize,
                             int prefetchCount,
                             boolean global)
                      throws IOException
        Public API - Request specific "quality of service" settings.

        These settings impose limits on the amount of data the server will deliver to consumers before requiring acknowledgements. Thus they provide a means of consumer-initiated flow control.

        Note the prefetch count must be between 0 and 65535 (unsigned short in AMQP 0-9-1).

        Specified by:
        basicQos in interface Channel
        Parameters:
        prefetchSize - maximum amount of content (measured in octets) that the server will deliver, 0 if unlimited
        prefetchCount - maximum number of messages that the server will deliver, 0 if unlimited
        global - true if the settings should be applied to the entire channel rather than each consumer
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Basic.Qos
      • basicQos

        public void basicQos​(int prefetchCount,
                             boolean global)
                      throws IOException
        Public API - Request a specific prefetchCount "quality of service" settings for this channel.

        Note the prefetch count must be between 0 and 65535 (unsigned short in AMQP 0-9-1).

        Specified by:
        basicQos in interface Channel
        Parameters:
        prefetchCount - maximum number of messages that the server will deliver, 0 if unlimited
        global - true if the settings should be applied to the entire channel rather than each consumer
        Throws:
        IOException - if an error is encountered
        See Also:
        Channel.basicQos(int, int, boolean)
      • basicQos

        public void basicQos​(int prefetchCount)
                      throws IOException
        Public API - Request a specific prefetchCount "quality of service" settings for this channel.

        Note the prefetch count must be between 0 and 65535 (unsigned short in AMQP 0-9-1).

        Specified by:
        basicQos in interface Channel
        Parameters:
        prefetchCount - maximum number of messages that the server will deliver, 0 if unlimited
        Throws:
        IOException - if an error is encountered
        See Also:
        Channel.basicQos(int, int, boolean)
      • basicPublish

        public void basicPublish​(String exchange,
                                 String routingKey,
                                 AMQP.BasicProperties props,
                                 byte[] body)
                          throws IOException
        Public API - Publish a message. Publishing to a non-existent exchange will result in a channel-level protocol exception, which closes the channel. Invocations of Channel#basicPublish will eventually block if a resource-driven alarm is in effect.
        Specified by:
        basicPublish in interface Channel
        Parameters:
        exchange - the exchange to publish the message to
        routingKey - the routing key
        props - other properties for the message - routing headers etc
        body - the message body
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Basic.Publish, Resource-driven alarms
      • basicPublish

        public void basicPublish​(String exchange,
                                 String routingKey,
                                 boolean mandatory,
                                 AMQP.BasicProperties props,
                                 byte[] body)
                          throws IOException
        Public API - Publish a message. Invocations of Channel#basicPublish will eventually block if a resource-driven alarm is in effect.
        Specified by:
        basicPublish in interface Channel
        Parameters:
        exchange - the exchange to publish the message to
        routingKey - the routing key
        mandatory - true if the 'mandatory' flag is to be set
        props - other properties for the message - routing headers etc
        body - the message body
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Basic.Publish, Resource-driven alarms
      • basicPublish

        public void basicPublish​(String exchange,
                                 String routingKey,
                                 boolean mandatory,
                                 boolean immediate,
                                 AMQP.BasicProperties props,
                                 byte[] body)
                          throws IOException
        Public API - Publish a message. Publishing to a non-existent exchange will result in a channel-level protocol exception, which closes the channel. Invocations of Channel#basicPublish will eventually block if a resource-driven alarm is in effect.
        Specified by:
        basicPublish in interface Channel
        Parameters:
        exchange - the exchange to publish the message to
        routingKey - the routing key
        mandatory - true if the 'mandatory' flag is to be set
        immediate - true if the 'immediate' flag is to be set. Note that the RabbitMQ server does not support this flag.
        props - other properties for the message - routing headers etc
        body - the message body
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Basic.Publish, Resource-driven alarms
      • exchangeDeclare

        public AMQImpl.Exchange.DeclareOk exchangeDeclare​(String exchange,
                                                          String type,
                                                          boolean durable,
                                                          boolean autoDelete,
                                                          Map<String,​Object> arguments)
                                                   throws IOException
        Public API - Declare an exchange.
        Specified by:
        exchangeDeclare in interface Channel
        Parameters:
        exchange - the name of the exchange
        type - the exchange type
        durable - true if we are declaring a durable exchange (the exchange will survive a server restart)
        autoDelete - true if the server should delete the exchange when it is no longer in use
        arguments - other properties (construction arguments) for the exchange
        Returns:
        a declaration-confirm method to indicate the exchange was successfully declared
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Exchange.Declare, AMQP.Exchange.DeclareOk
      • exchangeDeclare

        public AMQImpl.Exchange.DeclareOk exchangeDeclare​(String exchange,
                                                          BuiltinExchangeType type,
                                                          boolean durable,
                                                          boolean autoDelete,
                                                          Map<String,​Object> arguments)
                                                   throws IOException
        Public API - Declare an exchange.
        Specified by:
        exchangeDeclare in interface Channel
        Parameters:
        exchange - the name of the exchange
        type - the exchange type
        durable - true if we are declaring a durable exchange (the exchange will survive a server restart)
        autoDelete - true if the server should delete the exchange when it is no longer in use
        arguments - other properties (construction arguments) for the exchange
        Returns:
        a declaration-confirm method to indicate the exchange was successfully declared
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Exchange.Declare, AMQP.Exchange.DeclareOk
      • exchangeDeclareNoWait

        public void exchangeDeclareNoWait​(String exchange,
                                          String type,
                                          boolean durable,
                                          boolean autoDelete,
                                          boolean internal,
                                          Map<String,​Object> arguments)
                                   throws IOException
        Description copied from interface: Channel
        Like Channel.exchangeDeclare(String, String, boolean, boolean, java.util.Map) but sets nowait parameter to true and returns nothing (as there will be no response from the server).
        Specified by:
        exchangeDeclareNoWait in interface Channel
        Parameters:
        exchange - the name of the exchange
        type - the exchange type
        durable - true if we are declaring a durable exchange (the exchange will survive a server restart)
        autoDelete - true if the server should delete the exchange when it is no longer in use
        internal - true if the exchange is internal, i.e. can't be directly published to by a client.
        arguments - other properties (construction arguments) for the exchange
        Throws:
        IOException - if an error is encountered
      • exchangeDeclareNoWait

        public void exchangeDeclareNoWait​(String exchange,
                                          BuiltinExchangeType type,
                                          boolean durable,
                                          boolean autoDelete,
                                          boolean internal,
                                          Map<String,​Object> arguments)
                                   throws IOException
        Description copied from interface: Channel
        Like Channel.exchangeDeclare(String, String, boolean, boolean, java.util.Map) but sets nowait parameter to true and returns nothing (as there will be no response from the server).
        Specified by:
        exchangeDeclareNoWait in interface Channel
        Parameters:
        exchange - the name of the exchange
        type - the exchange type
        durable - true if we are declaring a durable exchange (the exchange will survive a server restart)
        autoDelete - true if the server should delete the exchange when it is no longer in use
        internal - true if the exchange is internal, i.e. can't be directly published to by a client.
        arguments - other properties (construction arguments) for the exchange
        Throws:
        IOException - if an error is encountered
      • exchangeDeclare

        public AMQImpl.Exchange.DeclareOk exchangeDeclare​(String exchange,
                                                          String type,
                                                          boolean durable,
                                                          boolean autoDelete,
                                                          boolean internal,
                                                          Map<String,​Object> arguments)
                                                   throws IOException
        Public API - Declare an exchange, via an interface that allows the complete set of arguments.
        Specified by:
        exchangeDeclare in interface Channel
        Parameters:
        exchange - the name of the exchange
        type - the exchange type
        durable - true if we are declaring a durable exchange (the exchange will survive a server restart)
        autoDelete - true if the server should delete the exchange when it is no longer in use
        internal - true if the exchange is internal, i.e. can't be directly published to by a client.
        arguments - other properties (construction arguments) for the exchange
        Returns:
        a declaration-confirm method to indicate the exchange was successfully declared
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Exchange.Declare, AMQP.Exchange.DeclareOk
      • exchangeDeclare

        public AMQImpl.Exchange.DeclareOk exchangeDeclare​(String exchange,
                                                          BuiltinExchangeType type,
                                                          boolean durable,
                                                          boolean autoDelete,
                                                          boolean internal,
                                                          Map<String,​Object> arguments)
                                                   throws IOException
        Public API - Declare an exchange, via an interface that allows the complete set of arguments.
        Specified by:
        exchangeDeclare in interface Channel
        Parameters:
        exchange - the name of the exchange
        type - the exchange type
        durable - true if we are declaring a durable exchange (the exchange will survive a server restart)
        autoDelete - true if the server should delete the exchange when it is no longer in use
        internal - true if the exchange is internal, i.e. can't be directly published to by a client.
        arguments - other properties (construction arguments) for the exchange
        Returns:
        a declaration-confirm method to indicate the exchange was successfully declared
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Exchange.Declare, AMQP.Exchange.DeclareOk
      • exchangeDeclare

        public AMQImpl.Exchange.DeclareOk exchangeDeclare​(String exchange,
                                                          String type,
                                                          boolean durable)
                                                   throws IOException
        Public API - Actively declare a non-autodelete exchange with no extra arguments
        Specified by:
        exchangeDeclare in interface Channel
        Parameters:
        exchange - the name of the exchange
        type - the exchange type
        durable - true if we are declaring a durable exchange (the exchange will survive a server restart)
        Returns:
        a declaration-confirm method to indicate the exchange was successfully declared
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Exchange.Declare, AMQP.Exchange.DeclareOk
      • exchangeDeclarePassive

        public AMQImpl.Exchange.DeclareOk exchangeDeclarePassive​(String exchange)
                                                          throws IOException
        Public API - Declare an exchange passively; that is, check if the named exchange exists.
        Specified by:
        exchangeDeclarePassive in interface Channel
        Parameters:
        exchange - check the existence of an exchange named this
        Throws:
        IOException - the server will raise a 404 channel exception if the named exchange does not exist.
      • exchangeBind

        public AMQImpl.Exchange.BindOk exchangeBind​(String destination,
                                                    String source,
                                                    String routingKey,
                                                    Map<String,​Object> arguments)
                                             throws IOException
        Public API - Bind an exchange to an exchange.
        Specified by:
        exchangeBind in interface Channel
        Parameters:
        destination - the name of the exchange to which messages flow across the binding
        source - the name of the exchange from which messages flow across the binding
        routingKey - the routing key to use for the binding
        arguments - other properties (binding parameters)
        Returns:
        a binding-confirm method if the binding was successfully created
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Exchange.Bind, AMQP.Exchange.BindOk
      • exchangeBindNoWait

        public void exchangeBindNoWait​(String destination,
                                       String source,
                                       String routingKey,
                                       Map<String,​Object> arguments)
                                throws IOException
        Public API - Like Channel.exchangeBind(String, String, String, java.util.Map) but sets nowait parameter to true and returns void (as there will be no response from the server).
        Specified by:
        exchangeBindNoWait in interface Channel
        Parameters:
        destination - the name of the exchange to which messages flow across the binding
        source - the name of the exchange from which messages flow across the binding
        routingKey - the routing key to use for the binding
        arguments - other properties (binding parameters)
        Throws:
        IOException - if an error is encountered
      • exchangeBind

        public AMQImpl.Exchange.BindOk exchangeBind​(String destination,
                                                    String source,
                                                    String routingKey)
                                             throws IOException
        Public API - Bind an exchange to an exchange, with no extra arguments.
        Specified by:
        exchangeBind in interface Channel
        Parameters:
        destination - the name of the exchange to which messages flow across the binding
        source - the name of the exchange from which messages flow across the binding
        routingKey - the routing key to use for the binding
        Returns:
        a binding-confirm method if the binding was successfully created
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Exchange.Bind, AMQP.Exchange.BindOk
      • exchangeUnbind

        public AMQImpl.Exchange.UnbindOk exchangeUnbind​(String destination,
                                                        String source,
                                                        String routingKey,
                                                        Map<String,​Object> arguments)
                                                 throws IOException
        Public API - Unbind an exchange from an exchange.
        Specified by:
        exchangeUnbind in interface Channel
        Parameters:
        destination - the name of the exchange to which messages flow across the binding
        source - the name of the exchange from which messages flow across the binding
        routingKey - the routing key to use for the binding
        arguments - other properties (binding parameters)
        Returns:
        a binding-confirm method if the binding was successfully created
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Exchange.Bind, AMQP.Exchange.BindOk
      • exchangeUnbind

        public AMQImpl.Exchange.UnbindOk exchangeUnbind​(String destination,
                                                        String source,
                                                        String routingKey)
                                                 throws IOException
        Public API - Unbind an exchange from an exchange, with no extra arguments.
        Specified by:
        exchangeUnbind in interface Channel
        Parameters:
        destination - the name of the exchange to which messages flow across the binding
        source - the name of the exchange from which messages flow across the binding
        routingKey - the routing key to use for the binding
        Returns:
        a binding-confirm method if the binding was successfully created
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Exchange.Bind, AMQP.Exchange.BindOk
      • exchangeUnbindNoWait

        public void exchangeUnbindNoWait​(String destination,
                                         String source,
                                         String routingKey,
                                         Map<String,​Object> arguments)
                                  throws IOException
        Public API - Same as Channel.exchangeUnbind(String, String, String, java.util.Map) but sets no-wait parameter to true and returns nothing (as there will be no response from the server).
        Specified by:
        exchangeUnbindNoWait in interface Channel
        Parameters:
        destination - the name of the exchange to which messages flow across the binding
        source - the name of the exchange from which messages flow across the binding
        routingKey - the routing key to use for the binding
        arguments - other properties (binding parameters)
        Throws:
        IOException - if an error is encountered
      • queueDeclare

        public AMQImpl.Queue.DeclareOk queueDeclare​(String queue,
                                                    boolean durable,
                                                    boolean exclusive,
                                                    boolean autoDelete,
                                                    Map<String,​Object> arguments)
                                             throws IOException
        Public API - Declare a queue
        Specified by:
        queueDeclare in interface Channel
        Parameters:
        queue - the name of the queue
        durable - true if we are declaring a durable queue (the queue will survive a server restart)
        exclusive - true if we are declaring an exclusive queue (restricted to this connection)
        autoDelete - true if we are declaring an autodelete queue (server will delete it when no longer in use)
        arguments - other properties (construction arguments) for the queue
        Returns:
        a declaration-confirm method to indicate the queue was successfully declared
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Queue.Declare, AMQP.Queue.DeclareOk
      • queueDeclareNoWait

        public void queueDeclareNoWait​(String queue,
                                       boolean durable,
                                       boolean exclusive,
                                       boolean autoDelete,
                                       Map<String,​Object> arguments)
                                throws IOException
        Public API - Like Channel.queueDeclare(String, boolean, boolean, boolean, java.util.Map) but sets nowait flag to true and returns no result (as there will be no response from the server).
        Specified by:
        queueDeclareNoWait in interface Channel
        Parameters:
        queue - the name of the queue
        durable - true if we are declaring a durable queue (the queue will survive a server restart)
        exclusive - true if we are declaring an exclusive queue (restricted to this connection)
        autoDelete - true if we are declaring an autodelete queue (server will delete it when no longer in use)
        arguments - other properties (construction arguments) for the queue
        Throws:
        IOException - if an error is encountered
      • queueDeclarePassive

        public AMQImpl.Queue.DeclareOk queueDeclarePassive​(String queue)
                                                    throws IOException
        Public API - Declare a queue passively; i.e., check if it exists. In AMQP 0-9-1, all arguments aside from nowait are ignored; and sending nowait makes this method a no-op, so we default it to false.
        Specified by:
        queueDeclarePassive in interface Channel
        Parameters:
        queue - the name of the queue
        Returns:
        a declaration-confirm method to indicate the queue exists
        Throws:
        IOException - if an error is encountered, including if the queue does not exist and if the queue is exclusively owned by another connection.
        See Also:
        AMQP.Queue.Declare, AMQP.Queue.DeclareOk
      • messageCount

        public long messageCount​(String queue)
                          throws IOException
        Public API - Returns the number of messages in a queue ready to be delivered to consumers. This method assumes the queue exists. If it doesn't, the channels will be closed with an exception.
        Specified by:
        messageCount in interface Channel
        Parameters:
        queue - the name of the queue
        Returns:
        the number of messages in ready state
        Throws:
        IOException - Problem transmitting method.
      • consumerCount

        public long consumerCount​(String queue)
                           throws IOException
        Public API - Returns the number of consumers on a queue. This method assumes the queue exists. If it doesn't, the channel will be closed with an exception.
        Specified by:
        consumerCount in interface Channel
        Parameters:
        queue - the name of the queue
        Returns:
        the number of consumers
        Throws:
        IOException - Problem transmitting method.
      • queueDelete

        public AMQImpl.Queue.DeleteOk queueDelete​(String queue,
                                                  boolean ifUnused,
                                                  boolean ifEmpty)
                                           throws IOException
        Public API - Delete a queue
        Specified by:
        queueDelete in interface Channel
        Parameters:
        queue - the name of the queue
        ifUnused - true if the queue should be deleted only if not in use
        ifEmpty - true if the queue should be deleted only if empty
        Returns:
        a deletion-confirm method to indicate the queue was successfully deleted
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Queue.Delete, AMQP.Queue.DeleteOk
      • basicAck

        public void basicAck​(long deliveryTag,
                             boolean multiple)
                      throws IOException
        Public API - Acknowledge one or several received messages. Supply the deliveryTag from the AMQP.Basic.GetOk or AMQP.Basic.Deliver method containing the received message being acknowledged.
        Specified by:
        basicAck in interface Channel
        Parameters:
        deliveryTag - the tag from the received AMQP.Basic.GetOk or AMQP.Basic.Deliver
        multiple - true to acknowledge all messages up to and including the supplied delivery tag; false to acknowledge just the supplied delivery tag.
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Basic.Ack
      • basicNack

        public void basicNack​(long deliveryTag,
                              boolean multiple,
                              boolean requeue)
                       throws IOException
        Public API - Reject one or several received messages. Supply the deliveryTag from the AMQP.Basic.GetOk or AMQP.Basic.GetOk method containing the message to be rejected.
        Specified by:
        basicNack in interface Channel
        Parameters:
        deliveryTag - the tag from the received AMQP.Basic.GetOk or AMQP.Basic.Deliver
        multiple - true to reject all messages up to and including the supplied delivery tag; false to reject just the supplied delivery tag.
        requeue - true if the rejected message(s) should be requeued rather than discarded/dead-lettered
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Basic.Nack
      • basicConsume

        public String basicConsume​(String queue,
                                   boolean autoAck,
                                   String consumerTag,
                                   boolean noLocal,
                                   boolean exclusive,
                                   Map<String,​Object> arguments,
                                   Consumer callback)
                            throws IOException
        Public API - Start a consumer. Calls the consumer's Consumer.handleConsumeOk(java.lang.String) method.
        Specified by:
        basicConsume in interface Channel
        Parameters:
        queue - the name of the queue
        autoAck - true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgements
        consumerTag - a client-generated consumer tag to establish context
        noLocal - true if the server should not deliver to this consumer messages published on this channel's connection
        exclusive - true if this is an exclusive consumer
        arguments - a set of arguments for the consume
        callback - an interface to the consumer object
        Returns:
        the consumerTag associated with the new consumer
        Throws:
        IOException - if an error is encountered
        See Also:
        AMQP.Basic.Consume, AMQP.Basic.ConsumeOk
      • basicRecover

        public AMQImpl.Basic.RecoverOk basicRecover()
                                             throws IOException
        Public API -

        Ask the broker to resend unacknowledged messages. In 0-8 basic.recover is asynchronous; in 0-9-1 it is synchronous, and the new, deprecated method basic.recover_async is asynchronous.

        Equivalent to calling basicRecover(true), messages will be requeued and possibly delivered to a different consumer.
        Specified by:
        basicRecover in interface Channel
        Throws:
        IOException
        See Also:
        Channel.basicRecover(boolean)
      • basicRecover

        public AMQImpl.Basic.RecoverOk basicRecover​(boolean requeue)
                                             throws IOException
        Public API - Ask the broker to resend unacknowledged messages. In 0-8 basic.recover is asynchronous; in 0-9-1 it is synchronous, and the new, deprecated method basic.recover_async is asynchronous.
        Specified by:
        basicRecover in interface Channel
        Parameters:
        requeue - If true, messages will be requeued and possibly delivered to a different consumer. If false, messages will be redelivered to the same consumer.
        Throws:
        IOException
      • getNextPublishSeqNo

        public long getNextPublishSeqNo()
        Public API - When in confirm mode, returns the sequence number of the next message to be published.
        Specified by:
        getNextPublishSeqNo in interface Channel
        Returns:
        the sequence number of the next message to be published
      • asyncRpc

        public void asyncRpc​(Method method)
                      throws IOException
        Description copied from interface: Channel
        Asynchronously send a method over this channel.
        Specified by:
        asyncRpc in interface Channel
        Parameters:
        method - method to transmit over this channel.
        Throws:
        IOException - Problem transmitting method.
      • rpc

        public AMQCommand rpc​(Method method)
                       throws IOException
        Description copied from class: AMQChannel
        Protected API - sends a Method to the broker and waits for the next in-bound Command from the broker: only for use from non-connection-MainLoop threads!
        Specified by:
        rpc in interface Channel
        Overrides:
        rpc in class AMQChannel
        Parameters:
        method - method to transmit over this channel.
        Returns:
        command response to method. Caller should cast as appropriate.
        Throws:
        IOException - Problem transmitting method.