Message API v2¶
For details on how to use message, see Using OpenStack Message
The Message v2 Class¶
The message high-level interface is available through the message
member
of a Connection
object. The message
member will only be added if the service is detected.
Message Operations¶
- class openstack.message.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- post_message(queue_name, messages)
Post messages to given queue
- Parameters
queue_name – The name of target queue to post message to.
messages (
list
) – List of messages body and TTL to post.
- Returns
A string includes location of messages successfully posted.
- messages(queue_name, **query)
Retrieve a generator of messages
- Parameters
queue_name – The name of target queue to query messages from.
query (kwargs) –
Optional query parameters to be sent to restrict the messages to be returned. Available parameters include:
- limit: Requests at most the specified number of items be
returned from the query.
- marker: Specifies the ID of the last-seen subscription. Use the
limit parameter to make an initial limited request and use the ID of the last-seen subscription from the response as the marker parameter value in a subsequent limited request.
- echo: Indicate if the messages can be echoed back to the client
that posted them.
- include_claimed: Indicate if the messages list should include
the claimed messages.
- Returns
A generator of message instances.
- get_message(queue_name, message)
Get a message
- Parameters
queue_name – The name of target queue to get message from.
message – The value can be the name of a message or a
Message
instance.
- Returns
One
Message
- Raises
ResourceNotFound
when no message matching the criteria could be found.
- delete_message(queue_name, value, claim=None, ignore_missing=True)
Delete a message
- Parameters
queue_name – The name of target queue to delete message from.
value – The value can be either the name of a message or a
Message
instance.claim – The value can be the ID or a
Claim
instance of the claim seizing the message. If None, the message has not been claimed.ignore_missing (bool) – When set to
False
ResourceNotFound
will be raised when the message does not exist. When set toTrue
, no exception will be set when attempting to delete a nonexistent message.
- Returns
None
Queue Operations¶
- class openstack.message.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- create_queue(**attrs)
Create a new queue from attributes
- Parameters
attrs (dict) – Keyword arguments which will be used to create a
Queue
, comprised of the properties on the Queue class.- Returns
The results of queue creation
- Return type
Queue
- get_queue(queue)
Get a queue
- Parameters
queue – The value can be the name of a queue or a
Queue
instance.- Returns
One
Queue
- Raises
ResourceNotFound
when no queue matching the name could be found.
- queues(**query)
Retrieve a generator of queues
- Parameters
query (kwargs) –
Optional query parameters to be sent to restrict the queues to be returned. Available parameters include:
- limit: Requests at most the specified number of items be
returned from the query.
- marker: Specifies the ID of the last-seen queue. Use the limit
parameter to make an initial limited request and use the ID of the last-seen queue from the response as the marker parameter value in a subsequent limited request.
- Returns
A generator of queue instances.
- delete_queue(value, ignore_missing=True)
Delete a queue
- Parameters
value – The value can be either the name of a queue or a
Queue
instance.ignore_missing (bool) – When set to
False
ResourceNotFound
will be raised when the queue does not exist. When set toTrue
, no exception will be set when attempting to delete a nonexistent queue.
- Returns
None
Claim Operations¶
- class openstack.message.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- create_claim(queue_name, **attrs)
Create a new claim from attributes
- Parameters
queue_name – The name of target queue to claim message from.
attrs (dict) – Keyword arguments which will be used to create a
Claim
, comprised of the properties on the Claim class.
- Returns
The results of claim creation
- Return type
Claim
- get_claim(queue_name, claim)
Get a claim
- Parameters
queue_name – The name of target queue to claim message from.
claim – The value can be either the ID of a claim or a
Claim
instance.
- Returns
One
Claim
- Raises
ResourceNotFound
when no claim matching the criteria could be found.
- update_claim(queue_name, claim, **attrs)
Update an existing claim from attributes
- Parameters
queue_name – The name of target queue to claim message from.
claim – The value can be either the ID of a claim or a
Claim
instance.attrs (dict) – Keyword arguments which will be used to update a
Claim
, comprised of the properties on the Claim class.
- Returns
The results of claim update
- Return type
Claim
- delete_claim(queue_name, claim, ignore_missing=True)
Delete a claim
- Parameters
queue_name – The name of target queue to claim messages from.
claim – The value can be either the ID of a claim or a
Claim
instance.ignore_missing (bool) – When set to
False
ResourceNotFound
will be raised when the claim does not exist. When set toTrue
, no exception will be thrown when attempting to delete a nonexistent claim.
- Returns
None
Subscription Operations¶
- class openstack.message.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- create_subscription(queue_name, **attrs)
Create a new subscription from attributes
- Parameters
queue_name – The name of target queue to subscribe on.
attrs (dict) – Keyword arguments which will be used to create a
Subscription
, comprised of the properties on the Subscription class.
- Returns
The results of subscription creation
- Return type
Subscription
- subscriptions(queue_name, **query)
Retrieve a generator of subscriptions
- Parameters
queue_name – The name of target queue to subscribe on.
query (kwargs) –
Optional query parameters to be sent to restrict the subscriptions to be returned. Available parameters include:
- limit: Requests at most the specified number of items be
returned from the query.
- marker: Specifies the ID of the last-seen subscription. Use the
limit parameter to make an initial limited request and use the ID of the last-seen subscription from the response as the marker parameter value in a subsequent limited request.
- Returns
A generator of subscription instances.
- get_subscription(queue_name, subscription)
Get a subscription
- Parameters
queue_name – The name of target queue of subscription.
message – The value can be the ID of a subscription or a
Subscription
instance.
- Returns
One
Subscription
- Raises
ResourceNotFound
when no subscription matching the criteria could be found.
- delete_subscription(queue_name, value, ignore_missing=True)
Delete a subscription
- Parameters
queue_name – The name of target queue to delete subscription from.
value – The value can be either the name of a subscription or a
Subscription
instance.ignore_missing (bool) – When set to
False
ResourceNotFound
will be raised when the subscription does not exist. When set toTrue
, no exception will be thrown when attempting to delete a nonexistent subscription.
- Returns
None