Module amqp_rpc_server2

This is a utility module that is used to expose an arbitrary function via an asynchronous RPC over AMQP mechanism.

Behaviours: gen_server.

Description

This is a utility module that is used to expose an arbitrary function via an asynchronous RPC over AMQP mechanism. It frees the implementor of a simple function from having to plumb this into AMQP. Note that the RPC server does not handle any data encoding, so it is up to the callback function to marshall and unmarshall message payloads accordingly.

The original RabbitMQ code by VMware has been altered to handle certain kinds of errors and to fit into a supervisor tree of a hosting application. Thus the intention is to embed server workers like these in the host application supervisor tree.

Function Index

start_link/3Starts a new RPC server instance that receives requests via a specified queue and dispatches them to a specified handler function.

Function Details

start_link/3

start_link(ConnectionRef, Config, RpcHandler) -> {ok, pid()}

Starts a new RPC server instance that receives requests via a specified queue and dispatches them to a specified handler function. You need to supply a connection reference to a connection_mgr process as well as the queue you want to listen on. Since the queue will be created if it does not already exist (and checked if it does), you also need to supply queue arguments. Currently in the RabbitMQ native format. There is no provision for marking queues as durable at the moment.

The function can return different kinds of messages depending on what it wants the server to do with the connection. You can either reply, ack, reject or finally reject the request with no requeueing.


Generated by EDoc