Module amqp_rpc_client2

This module allows the simple execution of an asynchronous RPC over AMQP.

Behaviours: gen_server.

Description

This module allows the simple execution of an asynchronous RPC over AMQP. It frees a client programmer of the necessary having to AMQP plumbing. Note that the this module does not handle any data encoding, so it is up to the caller to marshall and unmarshall message payloads accordingly.

NOTE: The way this AMQP Client is implemented, a caller will be blocked, but the gen_server run by this process will not. Tests on the local machine here easily obtains 8000+ reqs/s with this approach.

Function Index

await/1Equivalent to await(Name, infinity).
await/2Await the connection on a client.
call/3Equivalent to call(RpcClient, Payload, ContentType, 5000).
call/4Invokes an RPC.
call/5Invokes an RPC.
cast/4Send a fire-and-forget message to the exchange.
cast/5Send a fire-and-forget message to the exchange with a routing key This call acts like the call cast/4 except that it also allows the user to supply a routing key.
format_status/2
start_link/3Starts a new RPC client instance that sends requests to a specified queue.

Function Details

await/1

await(Name) -> term()

Equivalent to await(Name, infinity).

await/2

await(Name, Timeout) -> term()

Await the connection on a client. Await that a client has a connection to the server. This can be used in start-up sequences to ensure that you have a connection. It can be used to await in complex start-up sequences so you can be sure there is a connection. The timeout specifies for how long to wait.

call/3

call(RpcClient, Payload, ContentType) -> any()

Equivalent to call(RpcClient, Payload, ContentType, 5000).

call/4

call(RpcClient, Request, ContentType, Timeout) -> {ok, Payload, ContentType} | {error, Reason}

Invokes an RPC. Note the caller of this function is responsible for encoding the request and decoding the response. If the timeout is hit, the calling process will exit. The call will set ContentType as the type of the message (essentially the mime type). The Type of the message will always be set to request.

call/5

call(RpcClient, Request, ContentType, RoutingKey, Timeout) -> {ok, Payload, ContentType} | {error, Reason}

Invokes an RPC. And also use a routing key to route the message. This variant is equivalent to @ref call/4 but it also allows the caller to specify a routing key to use when publishing a message.

cast/4

cast(RpcClient, Payload, ContentType, Type) -> ok

Send a fire-and-forget message to the exchange. This implements the usual cast operation where a message is forwarded to a queue. Note that there is *no* guarantee that the message will be sent. In particular, if the queue is down, the message will be lost. You also have to supply a ContentType as well as a message type for the system.

cast/5

cast(RpcClient, Payload, ContentType, Type, RoutingKey) -> ok

Send a fire-and-forget message to the exchange with a routing key This call acts like the call cast/4 except that it also allows the user to supply a routing key

format_status/2

format_status(X1, X2) -> any()

start_link/3

start_link(Name, Configuration, ConnRef) -> {ok, pid()}

Starts a new RPC client instance that sends requests to a specified queue. This function returns the pid of the RPC client process that can be used to invoke RPCs and stop the client.


Generated by EDoc