spotter v0.6.0 Spotter.Testing.AmqpBlockingClient

A blocking AMPQ client for testing purposes and simple RPC use cases.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor

Initializes QoS, a queue and an exchanges for the channel

Returns the message from the certain queue if it exists

Initializes a new connection and a channel

Sends a new message without waiting for a response

Initializes a new blocking GenServer instance

Stop the client and close the existing connection

Link to this section Functions

Link to this function child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function configure_channel(pid, channel_opts, call_timeout \\ 500)

Initializes QoS, a queue and an exchanges for the channel.

The channel_opts parameters stores generic information about the response queue and the linked exchange. The call_timeout parameter determines maximum amount time in milliseconds before exit from the method by timeout.

Link to this function consume(pid, queue, timeout \\ 1000, attempts \\ 5, call_timeout \\ 500)

Returns the message from the certain queue if it exists.

The queue parameter represents the name of the queue which will be used for tracking responses. The timeout parameter determines amout of time before doing next attempt to extract the message. The attemps parameter determines the general amount of attempts to extract the message. The call_timeout parameter determines maximum amount time in milliseconds before exit from the method by timeout.

Initializes a new connection and a channel.

Link to this function send(pid, data, opts, call_timeout \\ 5000)

Sends a new message without waiting for a response.

The data parameter represents a payload, added to the message body. The ops parameter represented as a keyword, that can contain keys:

  • :request_exchange - Exchange key, through which will be published message.
  • :request_routing_key - Routing key, used for pushing message to the certain queue.
  • :mandatory - If set, returns an error if the broker can’t route the message to a queue (default false);
  • :immediate - If set, returns an error if the broker can’t deliver te message to a consumer immediately (default false);
  • :content_type - MIME Content type;
  • :content_encoding - MIME Content encoding;
  • :headers - Custom message headers;
  • :persistent - Determines delivery mode. Messages marked as persistent and delivered to durable queues will be logged to disk;
  • :correlation_id - Application correlation identifier;
  • :priority - Message priority, ranging from 0 to 9;
  • :reply_to - Name of the reply queue;
  • :expiration - How long the message is valid (in milliseconds);
  • :message_id - Message identifier;
  • :timestamp - Timestamp associated with this message (epoch time);
  • :type - Message type (as a string);
  • :user_id - User ID. Validated by RabbitMQ against the active connection user;
  • :app_id - Publishing application ID.

The call_timeout parameter determines maximum amount time in milliseconds before exit from the method by timeout.

Link to this function send_and_wait(pid, data, opts, timeout \\ 1000, attempts \\ 5, call_timeout \\ 5000)

Sends a new message and wait for result.

The data parameter represents a payload, added to the message body. The ops parameter represented as a keyword, that can contain keys:

  • :request_exchange - Exchange key, through which will be published message. Required.
  • :request_routing_key - Routing key, used for pushing message to the certain queue. Required.
  • :response_queue - The name of the queue which will be used for tracking responses. Required.
  • :channel_opts - Keyword list which is used for creating response queue and linking it with the exchange. Required.
  • :mandatory - If set, returns an error if the broker can’t route the message to a queue (default false);
  • :immediate - If set, returns an error if the broker can’t deliver te message to a consumer immediately (default false);
  • :content_type - MIME Content type;
  • :content_encoding - MIME Content encoding;
  • :headers - Custom message headers;
  • :persistent - Determines delivery mode. Messages marked as persistent and delivered to durable queues will be logged to disk;
  • :correlation_id - Application correlation identifier;
  • :priority - Message priority, ranging from 0 to 9;
  • :reply_to - Name of the reply queue;
  • :expiration - How long the message is valid (in milliseconds);
  • :message_id - Message identifier;
  • :timestamp - Timestamp associated with this message (epoch time);
  • :type - Message type (as a string);
  • :user_id - User ID. Validated by RabbitMQ against the active connection user;
  • :app_id - Publishing application ID.

The timeout parameter determines amout of time before doing next attempt to extract the message. The attemps parameter determines the general amount of attempts to extract the message. The call_timeout parameter determines maximum amount time in milliseconds before exit from the method by timeout.

Link to this function start_link(opts, name \\ __MODULE__)

Initializes a new blocking GenServer instance.

Stop the client and close the existing connection.