Module amqp_connection

This module is responsible for maintaining a connection to an AMQP broker and manages channels within the connection.

Description

This module is responsible for maintaining a connection to an AMQP broker and manages channels within the connection. This module is used to open and close connections to the broker as well as creating new channels within a connection.
The connections and channels created by this module are supervised under amqp_client's supervision tree. Please note that connections and channels do not get restarted automatically by the supervision tree in the case of a failure. If you need robust connections and channels, we recommend you use Erlang monitors on the returned connection and channel PID.

Data Types

amqp_params()

amqp_params() = #amqp_params{}

As defined in amqp_client.hrl. It contains the following fields:

Function Index

close/1Invokes close(ConnectionPid, 200, <<"Goodbye">>).
close/3Closes the AMQP connection, allowing the caller to set the reply code and text.
info/2Returns information about the connection, as specified by the Items list.
info_keys/0Returns a list of atoms that can be used in conjunction with info/2.
info_keys/1Returns a list of atoms that can be used in conjunction with info/2.
open_channel/1Invokes open_channel(ConnectionPid, none).
open_channel/2Opens an AMQP channel.
start/1Starts a connection to an AMQP server.
start/2Starts a connection to an AMQP server.

Function Details

close/1

close(ConnectionPid) -> any()

Invokes close(ConnectionPid, 200, <<"Goodbye">>).

close/3

close(ConnectionPid, Code, Text) -> ok | closing

Closes the AMQP connection, allowing the caller to set the reply code and text.

info/2

info(ConnectionPid, Items) -> ResultList

Returns information about the connection, as specified by the Items list. Item may be any atom returned by info_keys/1: server_properties - returns the server_properties fiels sent by the server while establishing the connection is_closing - returns true if the connection is in the process of closing and false otherwise amqp_params - returns the #amqp_params{} structure used to start the connection num_channels - returns the number of channels currently open under the connection (excluding channel 0) max_channel - returns the max_channel value negotiated with the server (only for the network connection) heartbeat - returns the heartbeat value negotiated with the server (only for the network connection) sock - returns the socket for the network connection (for use with e.g. inet:sockname/1) (only for the network connection) any other value - throws an exception

info_keys/0

info_keys() -> Items

Returns a list of atoms that can be used in conjunction with info/2. These are general info keys, which can be used in any type of connection. Other info keys may exist for a specific type. To get the full list of atoms that can be used for a certain connection, use info_keys/1.

info_keys/1

info_keys(ConnectionPid) -> Items

Returns a list of atoms that can be used in conjunction with info/2. Note that the list differs from a type of connection to another (network vs. direct). Use info_keys/0 to get a list of info keys that can be used for any connection.

open_channel/1

open_channel(ConnectionPid) -> any()

Invokes open_channel(ConnectionPid, none). Opens a channel without having to specify a channel number.

open_channel/2

open_channel(ConnectionPid, ChannelNumber) -> {ok, ChannelPid} | {error, Error}

Opens an AMQP channel.
This function assumes that an AMQP connection (networked or direct) has already been successfully established.
ChannelNumber must be less than or equal to the negotiated max_channel value, or less than or equal to ?MAX_CHANNEL_NUMBER if the negotiated max_channel value is 0.
In the direct connection, max_channel is always 0.

start/1

start(Type) -> {ok, Connection} | {error, Error}

Starts a connection to an AMQP server. Use network type to connect to a remote AMQP server - default connection settings are used, meaning that the server is expected to be at localhost:5672, with a vhost of "/" authorising a user guest/guest. Use direct type for a direct connection to a RabbitMQ server, assuming that the server is running in the same process space, and with a default set of amqp_params. If a different host, port, vhost or credential set is required, start/2 should be used.

start/2

start(Type, AmqpParams::amqp_params()) -> {ok, Connection} | {error, Error}

Starts a connection to an AMQP server. Use network type to connect to a remote AMQP server or direct type for a direct connection to a RabbitMQ server, assuming that the server is running in the same process space.


Generated by EDoc, Sep 14 2010, 09:26:42.