Module amqp_channel

This module encapsulates the client's view of an AMQP channel.

Behaviours: gen_server.

Description

This module encapsulates the client's view of an AMQP channel. Each server side channel is represented by an amqp_channel process on the client side. Channel processes are created using the amqp_connection module. Channel processes are supervised under amqp_client's supervision tree.

Data Types

amqp_method()

abstract datatype: amqp_method()

This abstract datatype represents the set of methods that comprise the AMQP execution model. As indicated in the overview, the attributes of each method in the execution model are described in the protocol documentation. The Erlang record definitions are autogenerated from a parseable version of the specification. Most fields in the generated records have sensible default values that you need not worry in the case of a simple usage of the client library.

amqp_msg()

amqp_msg() = #amqp_msg{}

This is the content encapsulated in content-bearing AMQP methods. It contains the following fields:

consume()

consume() = #'basic.consume'{}

The AMQP method that is used to subscribe a consumer to a queue.

Function Index

call/2This is equivalent to amqp_channel:call(Channel, Method, none).
call/3This sends an AMQP method on the channel.
cast/2This is equivalent to amqp_channel:cast(Channel, Method, none).
cast/3This function is the same as call/3, except that it returns immediately with the atom 'ok', without blocking the caller process.
close/1Closes the channel, invokes close(Channel, 200, <<"Goodbye">>).
close/3Closes the channel, allowing the caller to supply a reply code and text.
next_publish_seqno/1When in confirm mode, returns the sequence number of the next message to be published.
register_confirm_handler/2This registers a handler to deal with confirm-related messages.
register_default_consumer/2Set the current default consumer.
register_flow_handler/2This registers a handler to deal with channel flow notifications.
register_return_handler/2This registers a handler to deal with returned messages.
subscribe/3Creates a subscription to a queue.

Function Details

call/2

call(Channel, Method) -> Result

This is equivalent to amqp_channel:call(Channel, Method, none).

call/3

call(Channel, Method, Content) -> Result

This sends an AMQP method on the channel. For content bearing methods, Content has to be an amqp_msg(), whereas for non-content bearing methods, it needs to be the atom 'none'.
In the case of synchronous methods, this function blocks until the corresponding reply comes back from the server and returns it. In the case of asynchronous methods, the function blocks until the method gets sent on the wire and returns the atom 'ok' on success.
This will return the atom 'blocked' if the server has throttled the client for flow control reasons. This will return the atom 'closing' if the channel is in the process of shutting down.
Note that for asynchronous methods, the synchronicity implied by 'call' only means that the client has transmitted the method to the broker. It does not necessarily imply that the broker has accepted responsibility for the message.

cast/2

cast(Channel, Method) -> ok

This is equivalent to amqp_channel:cast(Channel, Method, none).

cast/3

cast(Channel, Method, Content) -> ok

This function is the same as call/3, except that it returns immediately with the atom 'ok', without blocking the caller process. This function is not recommended with synchronous methods, since there is no way to verify that the server has received the method.

close/1

close(Channel) -> ok

Closes the channel, invokes close(Channel, 200, <<"Goodbye">>).

close/3

close(Channel, Code, Text) -> ok

Closes the channel, allowing the caller to supply a reply code and text.

next_publish_seqno/1

next_publish_seqno(Channel) -> integer()

When in confirm mode, returns the sequence number of the next message to be published.

register_confirm_handler/2

register_confirm_handler(Channel, ConfirmHandler) -> ok

This registers a handler to deal with confirm-related messages. The registered process will receive #basic.ack{} and #basic.nack{} commands.

register_default_consumer/2

register_default_consumer(Channel, Consumer) -> ok

Set the current default consumer. Under certain circumstances it is possible for a channel to receive a message delivery which does not match any consumer which is currently set up via basic.consume. This will occur after the following sequence of events:

basic.consume with explicit acks
%% some deliveries take place but are not acked
basic.cancel
basic.recover{requeue = false}

Since requeue is specified to be false in the basic.recover, the spec states that the message must be redelivered to "the original recipient" - i.e. the same channel / consumer-tag. But the consumer is no longer active.
In these circumstances, you can register a default consumer to handle such deliveries. If no default consumer is registered then the channel will exit on receiving such a delivery.
Most people will not need to use this.

register_flow_handler/2

register_flow_handler(Channel, FlowHandler) -> ok

This registers a handler to deal with channel flow notifications. The registered process will receive #channel.flow{} records.

register_return_handler/2

register_return_handler(Channel, ReturnHandler) -> ok

This registers a handler to deal with returned messages. The registered process will receive #basic.return{} records.

subscribe/3

subscribe(Channel, BasicConsume::consume(), Consumer) -> amqp_method()

Creates a subscription to a queue. This subscribes a consumer pid to the queue defined in the #'basic.consume'{} method record. Note that both the process invoking this method and the supplied consumer process receive an acknowledgement of the subscription. The calling process will receive the acknowledgement as the return value of this function, whereas the consumer process will receive the notification asynchronously.


Generated by EDoc, Mar 22 2011, 17:49:23.