ExAliyun.MNS (ExAliyun.MNS v1.3.1)

The official link to introduce Alibaba Cloud Message Service.

Queue APIs

Topic APIs

Summary

Types

queue name

url for queue

subscription name

topic name

url for topic

Functions

Delete a list of messages from a MNS Queue in a single request.

Send up to 16 messages to a MNS Queue in a single request.

Modify the next consumable time of a message which has been consumed and is still in inactive status. After VisibilityTimeout of the message is modified successfully, a new ReceiptHandle will be returned.

Create a new message queue, the message queue name should be no more than 256 characters, and constituted by letters, digits, or hyphens (-), while the first character must be a letter.

Create a new topic, a topic name is a string of no more than 256 characters, including letters, numbers, and hyphens (-). It must start with a letter or number.

Delete a message from a MNS Queue.

Delete an existed message queue.

Delete an existing topic.

Get the attributes of a message queue.

Get the attributes of an existing topic.

List the available message queues.

List the subscriptions to a topic, support pagination query.

List the topics of an account.

View message(s) from a MNS Queue but do not change message(s) status.

Publish a message to a specified topic, the message is pushed to endpoints for consumption.

Read message(s) from a MNS Queue.

Send HTTP request, NO need to directly call this function by default.

Modify attributes of a message queue.

Modify notify_strategy of subscription attribute, the value of notify_strategy can be set as "BACKOFF_RETRY" or "EXPONENTIAL_DECAY_RETRY".

Modify the attributes of an existing topic.

Types

Link to this type

batch_message()

@type batch_message() ::
  String.t()
  | [message_body: String.t(), delay_seconds: 0..604_800, priority: 1..16]
Link to this type

batch_messages()

@type batch_messages() :: [batch_message()]
@type opts() :: Keyword.t()
Link to this type

queue_name()

@type queue_name() :: String.t()

queue name

example: "xxx-q"

@type queue_url() :: String.t()

url for queue

example: "/queues/xxx-q"

@type result() :: {:ok, map()} | {:error, map()} | {:error, term()}
Link to this type

subscription_name()

@type subscription_name() :: String.t()

subscription name

example: "xxx-s"

Link to this type

topic_name()

@type topic_name() :: String.t()

topic name

example: "xxx-t"

@type topic_url() :: String.t()

url for topic

example: "/topics/xxx-t"

Functions

Link to this function

batch_delete_message(queue_url, receipt_handles, opts \\ [])

@spec batch_delete_message(queue_url(), receipt_handles :: [String.t()], opts()) ::
  result()

Delete a list of messages from a MNS Queue in a single request.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details.
Link to this function

batch_send_message(queue_url, messages, opts \\ [])

Send up to 16 messages to a MNS Queue in a single request.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details.
Link to this function

change_message_visibility(queue_url, receipt_handle, visibility_timeout, opts \\ [])

@spec change_message_visibility(
  queue_url(),
  receipt_handle :: String.t(),
  visibility_timeout :: integer(),
  opts()
) :: result()

Modify the next consumable time of a message which has been consumed and is still in inactive status. After VisibilityTimeout of the message is modified successfully, a new ReceiptHandle will be returned.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details.
Link to this function

create_queue(queue_name, opts \\ [])

@spec create_queue(queue_name(), opts()) :: result()

Create a new message queue, the message queue name should be no more than 256 characters, and constituted by letters, digits, or hyphens (-), while the first character must be a letter.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details;
  • :delay_seconds, optional, message sent to the queue can be consumed after delay_seconds seconds, the valid value range in 0..604800 (7 days), by default is 0 second;
  • :maximum_message_size, optional, maximum body length of a message sent to the queue, measured in bytes, by default is 65536 (64 KB);
  • :message_retention_period, optional, maximum lifetime of the message in the queue, measured in seconds, the valid value range in 60..604800 seconds, by default is 259200 (3 days);
  • :visibility_timeout, optional, the valid value range in 1..43200 seconds (12 hours), by default is 30 seconds;
  • :polling_wait_seconds, optional, the valid value range in 0..30 seconds, by default is 0 second;
  • :logging_enabled, optional, whether to enable MNS server logging, by default is false.
Link to this function

create_topic(topic_name, opts \\ [])

@spec create_topic(topic_name(), opts()) :: result()

Create a new topic, a topic name is a string of no more than 256 characters, including letters, numbers, and hyphens (-). It must start with a letter or number.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details;
  • :maximum_message_size, optional, maximum body length of a message sent to the queue, measured in bytes, by default is 65536 (64 KB);
  • :logging_enabled, optional, whether to enable MNS server logging, by default is false.
Link to this function

delete_message(queue_url, receipt_handle, opts \\ [])

@spec delete_message(queue_url(), receipt_handle :: String.t(), opts()) :: result()

Delete a message from a MNS Queue.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details.
Link to this function

delete_queue(queue_url, opts \\ [])

@spec delete_queue(queue_url(), opts()) :: result()

Delete an existed message queue.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details.
Link to this function

delete_topic(topic_url, opts \\ [])

@spec delete_topic(topic_url(), opts()) :: result()

Delete an existing topic.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details.
Link to this function

get_queue_attributes(queue_url, opts \\ [])

@spec get_queue_attributes(queue_url(), opts()) :: result()

Get the attributes of a message queue.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details.
Link to this function

get_subscription_attributes(topic_url, subscription_name, opts \\ [])

@spec get_subscription_attributes(topic_url(), subscription_name(), opts()) ::
  result()

Get subscription attributes.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details.
Link to this function

get_topic_attributes(topic_url, opts \\ [])

@spec get_topic_attributes(topic_url(), opts()) :: result()

Get the attributes of an existing topic.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details.
Link to this function

list_queues(opts \\ [])

@spec list_queues(opts()) :: result()

List the available message queues.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details;
  • :queue_name_prefix, optional, search for the queue name starting with this prefix;
  • :number, optional, maximum number of results returned for a single request, the valid value range in 1..1000, by default is 1000;
  • :marker, optional, a similar pagination cursor when list a large queues list, which is acquired from the NextMarker returned in the previous request.
Link to this function

list_subscriptions(topic_url, opts \\ [])

@spec list_subscriptions(topic_url(), opts()) :: result()

List the subscriptions to a topic, support pagination query.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details;
  • :subscription_name_prefix, optional, search for the subscription name starting with this prefix;
  • :number, optional, maximum number of results returned for a single request, the valid value range in 1..1000, by default is 1000;
  • :marker, optional, a similar pagination cursor when list a large subscriptions list, which is acquired from the NextMarker returned in the previous request.
Link to this function

list_topics(opts \\ [])

@spec list_topics(opts()) :: result()

List the topics of an account.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details;
  • :topic_name_prefix, optional, search for the topic name starting with this prefix;
  • :number, optional, maximum number of results returned for a single request, the valid value range in 1..1000, by default is 1000;
  • :marker, optional, a similar pagination cursor when list a large topics list, which is acquired from the NextMarker returned in the previous request.
Link to this function

peek_message(queue_url, opts \\ [])

@spec peek_message(queue_url(), opts()) :: result()

View message(s) from a MNS Queue but do not change message(s) status.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details;
  • :number, optional, maximum number of messages can be viewed for the current operation (see BatchPeekMessage doc), the default number is 1, the maximum number is 16.
Link to this function

publish_topic_message(topic_url, message_body, opts \\ [])

@spec publish_topic_message(topic_url(), message_body :: String.t(), opts()) ::
  result()

Publish a message to a specified topic, the message is pushed to endpoints for consumption.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details;
  • :message_tag, optional, a string no more than 16 characters, there is no message tag set by default;
  • :message_attributes, optional, a string of message attributes, only be useable for email or SMS push, please see API documents for details.
Link to this function

receive_message(queue_url, opts \\ [])

@spec receive_message(queue_url(), opts()) :: result()

Read message(s) from a MNS Queue.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details;
  • :wait_time_seconds, optional, the maximum wait time for polling message in current request, settable value range is 0..30 (seconds), if not set this option will use Queue's polling_wait_seconds attribute (see create_queue/2) as default.
  • :number, optional, receive up to 16 messages (doc) from a MNS Queue in a single request, by default as 1.
Link to this function

request(operation, config_overrides \\ [], http_opts \\ [])

Send HTTP request, NO need to directly call this function by default.

The following options all are optional, but they are requeired to identify request's authorization in every operation request, we can set them as a global config:

config :ex_aliyun_mns,
  access_key_id: "",
  access_key_secret: "",
  host: ""

Or set these option(s) via config_overrides option to dynamically set/override in each operation request.

Config options

  • access_key_id, optional, the access key id of Alibaba Cloud RAM for MNS;
  • access_key_secret, optional, the access key secret of Alibaba Cloud RAM for MNS;
  • host, optional, the MNS's regions to request, the available regions can be found in MNS's console, e.g. "https://xxxx.mns.us-east-1.aliyuncs.com".

Http options

  • timeout, optional, time in milliseconds, used when receiving data over a connection, default it 15_000.
Link to this function

send_message(queue_url, message_body, opts \\ [])

@spec send_message(queue_url(), message_body :: String.t(), opts()) :: result()

Sand a message to MNS Queue.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details;
  • :delay_seconds, optional, message sent to the queue can be consumed after delay_seconds seconds, the valid value range in 0..604800 (7 days), by default is 0 second;
  • :priority
Link to this function

set_queue_attributes(queue_url, opts \\ [])

@spec set_queue_attributes(queue_url(), opts()) :: result()

Modify attributes of a message queue.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details;
  • :delay_seconds, optional, message sent to the queue can be consumed after delay_seconds seconds, the valid value range in 0..604800 (7 days), by default is 0 second;
  • :maximum_message_size, optional, maximum body length of a message sent to the queue, measured in bytes, by default is 65536 (64 KB);
  • :message_retention_period, optional, maximum lifetime of the message in the queue, measured in seconds, the valid value range in 60..604800 seconds, by default is 259200 (3 days);
  • :visibility_timeout, optional, the valid value range in 1..43200 seconds (12 hours), by default is 30 seconds;
  • :polling_wait_seconds, optional, the valid value range in 0..30 seconds, by default is 0 second;
  • :logging_enabled, optional, whether to enable MNS server logging, by default is false.
Link to this function

set_subscription_attributes(topic_url, subscription_name, notify_strategy, opts \\ [])

@spec set_subscription_attributes(
  topic_url(),
  subscription_name(),
  notify_strategy :: String.t(),
  opts()
) :: result()

Modify notify_strategy of subscription attribute, the value of notify_strategy can be set as "BACKOFF_RETRY" or "EXPONENTIAL_DECAY_RETRY".

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details.
Link to this function

set_topic_attributes(topic_url, opts)

@spec set_topic_attributes(topic_url(), opts()) :: result()

Modify the attributes of an existing topic.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details;
  • :maximum_message_size, optional, maximum body length of a message sent to the queue, measured in bytes, by default is 65536 (64 KB);
  • :logging_enabled, optional, whether to enable MNS server logging, by default is false.
Link to this function

subscribe(topic_url, subscription_name, endpoint, opts \\ [])

@spec subscribe(topic_url(), subscription_name(), endpoint :: String.t(), opts()) ::
  result()

Create a subscription to a topic.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details;
  • :filter_tag, optional, a string no more than 16 characters, there is no message filter set by default;
  • :notify_strategy, optional, "BACKOFF_RETRY" or "EXPONENTIAL_DECAY_RETRY", as "BACKOFF_RETRY" by default;
  • :notify_content_format, optional, "XML", "JSON", or "SIMPLIFIED", as "XML" by default
Link to this function

unsubscribe(topic_url, subscription_name, opts \\ [])

@spec unsubscribe(topic_url(), subscription_name(), opts()) :: result()

Cancel a subscription.

Alibaba Cloud API Docs

Options

  • :config_overrides, optional, the options in config_overrides, please see request/2 for details.