class

AMQP::Client::Channel

Inherits Reference < Object

Instance methods

basic_ack(delivery_tag : UInt64, multiple = false) : Nil

Acknowledge a message with delivery_tag, or all message up and including delivery_tag if multiple set set

Source
basic_cancel(consumer_tag, no_wait = false) : Nil

Cancel the consumer with the consumer_tag Even with no_wait = false the method will return immediately, but outstanding deliveries will be processed.

Source
basic_consume(queue, tag = "", no_ack = true, exclusive = false, block = false, args arguments : NamedTuple = NamedTuple.new, work_pool = 1, &blk : DeliverMessage -> Nil)
Source
basic_consume(queue, tag = "", no_ack = true, exclusive = false, block = false, args arguments = Arguments.new, work_pool = 1, &blk : DeliverMessage -> Nil)

Consume messages from a queue

  • Make sure to eventually ack or reject each message if no_ack is false
  • The exclusive flags ensures that only a single consumer receives messages from the queue at the time
  • The method will block if the flag is set, until the consumer/channel/connection is closed or the callback raises an exception
  • To let multiple fibers process messages increase work_pool Make sure to handle all exceptions in the consume block, as unhandeled exceptions will cause the channel to be closed (to prevent dangling unacked messages and exception floods).
Source
basic_get(queue : String, no_ack = true) : GetMessage | Nil

Get a single message from a queue The message must eventually be acked or rejected if no_ack is false

Source
basic_nack(delivery_tag : UInt64, requeue = false, multiple = false) : Nil

Reject a message with delivery_tag, optionally requeue it Reject all message up to and including delivery_tag if multiple is true

Source
basic_publish(bytes : Bytes, exchange : String, routing_key = "", mandatory = false, immediate = false, props properties = Properties.new)

Publish a bytes message, to an exchange with routing_key

Source
basic_publish(bytes : Bytes, exchange : String, routing_key = "", mandatory = false, immediate = false, props properties = Properties.new, &blk : Bool -> Nil)
Source
basic_publish(string : String, exchange : String, routing_key = "", mandatory = false, immediate = false, props properties = Properties.new)

Publish a string message, to an exchange with routing_key

Source
basic_publish(string : String, exchange : String, routing_key = "", mandatory = false, immediate = false, props properties = Properties.new, &blk : Bool -> Nil)
Source
basic_publish(io : IO::Memory | IO::FileDescriptor, exchange : String, routing_key = "", mandatory = false, immediate = false, props properties = Properties.new)

Publish an io message, to an exchange with routing_key Only data from the current position of the IO to the end will be published. The position will be restored after publish.

Source
basic_publish(io : IO::Memory | IO::FileDescriptor, exchange : String, routing_key = "", mandatory = false, immediate = false, props properties = Properties.new, &blk : Bool -> Nil)
Source
basic_publish(body : IO | Bytes, bytesize : Int, exchange : String, routing_key = "", mandatory = false, immediate = false, props properties = Properties.new, &blk : Bool -> Nil) : UInt64
Source
basic_publish(body : IO | Bytes, bytesize : Int, exchange : String, routing_key = "", mandatory = false, immediate = false, props properties = Properties.new, blk : Proc(Bool, Nil) | Nil = nil) : UInt64

Publish a message with a set bytesize, to an exchange with routing_key

Source
basic_publish_confirm(io : IO, bytesize : Int, exchange : String, routing_key = "", mandatory = false, immediate = false, props properties = Properties.new) : Bool
Source
basic_publish_confirm(msg, exchange, routing_key = "", mandatory = false, immediate = false, props properties = Properties.new) : Bool
Source
basic_qos(count, global = false) : Nil

Set prefetch limit to count messages, no more messages will be delivered to the consumer until one or more message have been acknowledged or rejected

Source
basic_recover(requeue : Bool) : Nil

Tell the broker to either deliver all unacknowledge messages again if requeue is false or rejecting all if requeue is true

Unacknowledged messages retrived by basic_get are requeued regardless.

Source
basic_reject(delivery_tag : UInt64, requeue = false) : Nil

Reject a message with delivery_tag, optionally requeue it

Source
close(reason = "", code = 200) : Nil

Close the channel The reason might be logged by the server

Source
closed?
Source
confirm_select(no_wait = false) : Nil

Sets the channel in publish confirm mode, each published message will be acked or nacked

Source
default_exchange
Source
direct_exchange(name = "amq.direct", passive = true)
Source
exchange(name, type, passive = false, durable = true, internal = false, auto_delete = false, args arguments : NamedTuple = NamedTuple.new)
Source
exchange(name, type, passive = false, durable = true, internal = false, auto_delete = false, args arguments = Arguments.new)

Convinence method for Exchange handling

Source
exchange_bind(source : String, destination : String, routing_key : String, no_wait = false, args arguments : NamedTuple = NamedTuple.new) : Nil
Source
exchange_bind(source : String, destination : String, routing_key : String, no_wait = false, args arguments = Arguments.new) : Nil

Bind an exchange to another exchange

Source
exchange_declare(name : String, type : String, passive = false, durable = true, internal = false, auto_delete = false, no_wait = false, args arguments : NamedTuple = NamedTuple.new) : Nil
Source
exchange_declare(name : String, type : String, passive = false, durable = true, internal = false, auto_delete = false, no_wait = false, args arguments = Arguments.new) : Nil

Declares an exchange

Source
exchange_delete(name, if_unused = false, no_wait = false) : Nil

Deletes an exchange

Source
exchange_unbind(source : String, destination : String, routing_key : String, no_wait = false, args arguments : NamedTuple = NamedTuple.new) : Nil
Source
exchange_unbind(source : String, destination : String, routing_key : String, no_wait = false, args arguments = Arguments.new) : Nil

Unbind an exchange from another exchange

Source
fanout_exchange(name = "amq.fanout", passive = true)
Source
flow(active : Bool)

Stop/start the flow of messages to consumers Not supported by all brokers

Source
header_exchange(name = "amq.header", passive = true)
Source
inspect(io : IO) : Nil

Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).inspect # => #<Person:0x10fd31f20 @name="John", @age=32>
Source
on_cancel

Callback that will be called if a consumer is cancelled by the server The argument to the callback is the consumer tag

Source
on_close

Callback that will be called if the channel is closed by the server

Source
on_return

Callback that is called if a published message is returned by the server

Source
prefetch(count, global = false) : Nil

Alias for basic_qos

Source
queue(name : String, passive = false, durable = true, exclusive = false, auto_delete = false, args arguments : NamedTuple = NamedTuple.new)
Source
queue(name : String, passive = false, durable = true, exclusive = false, auto_delete = false, args arguments = Arguments.new)

Declares a queue with a name, by default durable and not auto-deleted

Source
queue

Declares a temporary queue, which won't be durable and auto-deleted when not used anymore

Source
queue_bind(queue : String, exchange : String, routing_key : String, no_wait = false, args arguments : NamedTuple = NamedTuple.new) : Nil
Source
queue_bind(queue : String, exchange : String, routing_key : String, no_wait = false, args arguments = Arguments.new) : Nil

Bind a queue to an exchange, with a routing_key and optionally some arguments

Source
queue_declare(name : String, passive = false, durable = name.empty? ? false : true, exclusive = name.empty? ? true : false, auto_delete = name.empty? ? true : false, no_wait = false, args arguments : NamedTuple = NamedTuple.new)
Source
queue_declare(name : String, passive = false, durable = name.empty? ? false : true, exclusive = name.empty? ? true : false, auto_delete = name.empty? ? true : false, no_wait = false, args arguments = Arguments.new)

Declare a queue with name passive will raise if the queue doesn't already exists, other arguments are ignored durable will make the queue durable on the server (note that messages have have the persistent flag set to make the messages persistent) exclusive will make the queue exclusive to the channel and will be deleted when the channel is closed auto_delete will delete the queue when the last consumer as stopped consuming no_wait will cause the method to return without waiting for a confirmation from the server

Source
queue_delete(name : String, if_unused = false, if_empty = false, no_wait = false)

Delete a queue

Source
queue_purge(name : String, no_wait = false)

Purge/empty a queue, will return the number of messages deleted

Source
queue_unbind(queue : String, exchange : String, routing_key : String, args arguments : NamedTuple = NamedTuple.new) : Nil
Source
queue_unbind(queue : String, exchange : String, routing_key : String, args arguments = Arguments.new) : Nil

Unbind a queue from an exchange, with a routing_key and optionally some arguments

Source
topic_exchange(name = "amq.topic", passive = true)
Source
transaction

Commits a transaction if the block returns, rolls back the transaction if the block raises an exception

Source
tx_commit

Commit a transaction

Source
tx_rollback

Rollback a transaction

Source
tx_select

Set the Channel in transaction mode

Source
wait_for_confirms

Returns when there are no unconfirmed publishes on the channel Raises if there was any negative acknowledgements

Source

Nested types