ExAliyun.MNS (ExAliyun.MNS v1.3.1)
The official link to introduce Alibaba Cloud Message Service.
Queue APIs
batch_send_message/2
batch_delete_message/3
change_message_visibility/4
create_queue/2
delete_message/3
delete_queue/2
get_queue_attributes/2
list_queues/1
peek_message/2
send_message/3
set_queue_attributes/2
receive_message/2
Topic APIs
Summary
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 subscription attributes.
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.
Sand a message to MNS Queue.
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.
Create a subscription to a topic.
Cancel a subscription.
Types
batch_message()
batch_messages()
@type batch_messages() :: [batch_message()]
opts()
@type opts() :: Keyword.t()
queue_name()
@type queue_name() :: String.t()
queue name
example: "xxx-q"
queue_url()
@type queue_url() :: String.t()
url for queue
example: "/queues/xxx-q"
result()
subscription_name()
@type subscription_name() :: String.t()
subscription name
example: "xxx-s"
topic_name()
@type topic_name() :: String.t()
topic name
example: "xxx-t"
topic_url()
@type topic_url() :: String.t()
url for topic
example: "/topics/xxx-t"
Functions
batch_delete_message(queue_url, receipt_handles, opts \\ [])
Delete a list of messages from a MNS Queue in a single request.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/2
for details.
batch_send_message(queue_url, messages, opts \\ [])
Send up to 16 messages to a MNS Queue in a single request.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/2
for details.
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.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/2
for details.
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.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/2
for details;:delay_seconds
, optional, message sent to the queue can be consumed afterdelay_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.
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.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/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.
delete_message(queue_url, receipt_handle, opts \\ [])
Delete a message from a MNS Queue.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/2
for details.
delete_queue(queue_url, opts \\ [])
Delete an existed message queue.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/2
for details.
delete_topic(topic_url, opts \\ [])
Delete an existing topic.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/2
for details.
get_queue_attributes(queue_url, opts \\ [])
Get the attributes of a message queue.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/2
for details.
get_subscription_attributes(topic_url, subscription_name, opts \\ [])
@spec get_subscription_attributes(topic_url(), subscription_name(), opts()) :: result()
Get subscription attributes.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/2
for details.
get_topic_attributes(topic_url, opts \\ [])
Get the attributes of an existing topic.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/2
for details.
list_queues(opts \\ [])
List the available message queues.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/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 theNextMarker
returned in the previous request.
list_subscriptions(topic_url, opts \\ [])
List the subscriptions to a topic, support pagination query.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/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 theNextMarker
returned in the previous request.
list_topics(opts \\ [])
List the topics of an account.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/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 theNextMarker
returned in the previous request.
peek_message(queue_url, opts \\ [])
View message(s) from a MNS Queue but do not change message(s) status.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/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.
publish_topic_message(topic_url, message_body, opts \\ [])
Publish a message to a specified topic, the message is pushed to endpoints for consumption.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/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.
receive_message(queue_url, opts \\ [])
Read message(s) from a MNS Queue.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/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'spolling_wait_seconds
attribute (seecreate_queue/2
) as default.:number
, optional, receive up to 16 messages (doc) from a MNS Queue in a single request, by default as 1.
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 it15_000
.
send_message(queue_url, message_body, opts \\ [])
Sand a message to MNS Queue.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/2
for details;:delay_seconds
, optional, message sent to the queue can be consumed afterdelay_seconds
seconds, the valid value range in 0..604800 (7 days), by default is 0 second;:priority
set_queue_attributes(queue_url, opts \\ [])
Modify attributes of a message queue.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/2
for details;:delay_seconds
, optional, message sent to the queue can be consumed afterdelay_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.
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"
.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/2
for details.
set_topic_attributes(topic_url, opts)
Modify the attributes of an existing topic.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/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.
subscribe(topic_url, subscription_name, endpoint, opts \\ [])
@spec subscribe(topic_url(), subscription_name(), endpoint :: String.t(), opts()) :: result()
Create a subscription to a topic.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/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
unsubscribe(topic_url, subscription_name, opts \\ [])
@spec unsubscribe(topic_url(), subscription_name(), opts()) :: result()
Cancel a subscription.
Options
:config_overrides
, optional, the options inconfig_overrides
, please seerequest/2
for details.