File: getting_started.rst

package info (click to toggle)
zaqar 21.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,964 kB
  • sloc: python: 28,819; sh: 513; java: 135; makefile: 63; javascript: 50
file content (387 lines) | stat: -rw-r--r-- 11,218 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
=====================
Getting Started Guide
=====================

Overview
--------

Messaging service is a RESTful API-based messaging
service. It supports distributed web applications,and is based on the
OpenStack Zaqar project.

Messaging service is a vital component of large, distributed
web applications. You can use Messaging service for public,
private, and hybrid cloud environments.

As you develop distributed web applications, you often have multiple
agents set up to complete sets of tasks for those applications. These
tasks can be anything from creating users to deleting blocks of storage.
Messaging service provides a simple interface that creates these tasks as
queues, messages, and claims. The interface then posts, claims, reads,
and deletes them as the tasks are needed and performed.

Messaging service handles the distribution of tasks, but it does not
necessarily manage the order of the tasks. Applications handle the
workflow at a higher level.

This guide explains how to access and start using the API so that you
can begin to use Messaging service for your applications. Instructions are
given for how to properly enter the necessary URLs, using cURL, to set
up and use a basic set of Messaging service operations.

Prerequisites for Running Examples
----------------------------------

In order to run the examples in this guide, you must have the following
prerequisites:

-  A Cloud account

-  A username and password, as specified during registration

-  Prior knowledge of HTTP/1.1 conventions

-  Basic familiarity with Cloud and RESTful APIs

How Messaging service Works
---------------------------

Following is an overview of how Messaging service works. For definitions
of Messaging service terms, see the below glossary.

1. You create a queue to which producers or publishers post messages.

2. Workers (consumers or subscribers) claim or get a message from the
   queue, complete the work in that message, and delete the message.

   If a worker will be off-line before it completes the work in a
   message, the worker can retire the claim's time to live (TTL),
   putting the message back into the queue for another worker to claim.

3. Subscribers monitor the claims from these queues to track activity
   and help troubleshoot errors.

For the majority of use cases, Messaging service is not responsible for
the ordering of messages. However, if there is only a single producer,
Messaging service ensures that messages are handled in a First In, First
Out (FIFO) order.

Messaging Patterns
------------------

The Messaging service API supports a variety of messaging patterns
including the following:

-  Task distribution

-  Event broadcasting

-  Point-to-point messaging

Task distribution
-----------------

The task distribution pattern has the following characteristics:

-  A producer is programmed to send messages to a queue.

-  Multiple workers (or consumers) are programmed to monitor a queue.

-  Only one worker can claim a message so that no other worker can claim
   the message and duplicate the work.

-  The worker must delete the message when work is done.

-  TTL restores a message to an unclaimed state if the worker never
   finishes.

This pattern is ideal for dispatching jobs to multiple processors.

Event Broadcasting
------------------

Characteristics of the event broadcasting pattern are:

-  The publisher sends messages to a queue.

-  Multiple observers (or subscribers) get the messages in the queue.

-  Multiple observers take action on each message.

-  Observers send a marker to skip messages already seen.

-  TTL eventually deletes messages.

This pattern is ideal for notification of events to multiple observers
at once.

Point-to-point messaging
------------------------

Characteristics of the point-to-point messaging pattern are:

-  The publisher sends messages to a queue.

-  The consumer gets the messages in the queue.

-  The consumer can reply with the result of processing a message by
   sending another message to the same queue (queues are duplex by
   default).

-  The publisher gets replies from the queue.

-  The consumer sends a marker to skip messages already seen.

-  TTL eventually deletes messages.

This pattern is ideal for communicating with a specific client,
especially when a reply is desired from that client.

Messaging service Operations
----------------------------

This section lists all of the operations that are available in the
Messaging service API. This document uses some of the most common
operations in `OpenStack API Reference <https://docs.openstack.org/api-quick-start/index.html>`__..

For details about all of the operations, see the Messaging service API v2
Reference.

Home Document
~~~~~~~~~~~~~

The following operation is available for the home document:

-  Get Home Document

Queues
~~~~~~

The following operations are available for queues:

-  Create Queue

-  List Queues

-  Get Queue

-  Update Queue

-  Get Queue Stats

-  Delete Queue

Messages
~~~~~~~~

The following operations are available for messages:

-  Post Message

-  Get Messages

-  Get a Specific Message

-  Get a Set of Messages by ID

-  Delete Message

-  Delete a Set of Messages by ID

Claims
~~~~~~

The following operations are available for claims:

-  Claim Messages

-  Get Claim

-  Update Claim

-  Release Claim

Subscriptions
~~~~~~~~~~~~~

The following operations are available for subscriptions:

-  Create Subscriptions

-  List Subscriptions

-  Get Subscription

-  Update Subscription

-  Delete Subscription


Pools
~~~~~

The following operations are available for Pools:

-  Create Pools

-  List Pools

-  Get Pool

-  Update Pool

-  Delete Pool

Flavors
~~~~~~~

The following operations are available for Flavors:

-  Create Flavors

-  List Flavors

-  Get Flavor

-  Update Flavors

-  Delete Flavors


Health
~~~~~~

The following operations are available for Health:

- Ping for basic health status

- Get detailed health status


Use Cases
---------

Queuing systems are used to coordinate tasks within an application. Here
are some examples:

-  **Backup**: A backup application might use a queuing system to
   connect the actions that users do in the a control panel to the
   customer's backup agent on a server. When a customer wants to start a
   backup, they simply choose "start backup" on a panel. Doing so causes
   the producer to put a "startBackup" message into the queue. Every few
   minutes, the agent on the customers server (the worker) checks the
   queue to see if it has any new messages to act on. The agent claims
   the "startBackup" message and kicks off the backup on the customer's
   server.

-  **Storage**: Gathering statistics for a large, distributed storage
   system can be a long process. The storage system can use a queuing
   system to ensure that jobs complete, even if one initially fails.
   Since messages are not deleted until after the worker has completed
   the job, the storage system can make sure that no job goes undone. If
   the worker fails to complete the job, the message stays in the queue
   to be completed by another server. In this case, a worker claims a
   message to perform a statistics job, but the claim's TTL expired and
   the message is put back into the queue when the job took too long to
   complete (meaning that it most likely failed). By giving the claim a
   TTL, applications can protect themselves from workers going off-line
   while processing a message. After a claim's TTL expires, the message
   is put back into the queue for another worker to claim.

-  **Email**: The team for an email application is constantly migrating
   customer email from old versions to newer ones, so they develop a
   tool to let customers do it themselves. The migrations take a long
   time, so they cannot be done with single API calls, or by a single
   server. When a user starts a migration job from their portal, the
   migration tool sends messages to the queue with details of how to run
   the migration. A set of migration engines, the consumers in this
   case, periodically check the queues for new migration tasks, claim
   the messages, perform the migration, and update a database with the
   migration details. This process allows a set of servers to work
   together to accomplish large migrations in a timely manner.

Following are some generic use cases for Messaging service:

-  Distribute tasks among multiple workers (transactional job queues)

-  Forward events to data collectors (transactional event queues)

-  Publish events to any number of subscribers (event broadcasting)

-  Send commands to one or more agents (point-to-point messaging or
   event broadcasting)

-  Request an action or get information from a Remote Procedure Call
   (RPC) agent (point-to-point messaging)

Additional Resources
--------------------

For more information about using the API, see the Messaging service API v2
Reference. All you need to get started with Messaging service is the
getting started guide, the reference, and your Cloud account.

For information about the OpenStack Zaqar API, see
`OpenStack API Reference <https://docs.openstack.org/api-quick-start/index.html>`__.

This API uses standard HTTP 1.1 response codes as documented at
`www.w3.org/Protocols/rfc2616/rfc2616-sec10.html <http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html>`__.

Glossary
--------

**Claim**
The process of a worker checking out a message to perform a task.
Claiming a message prevents other workers from attempting to process the
same messages.

**Claim TTL**
Defines how long a message will be in claimed state. A message can be
claimed by one worker at a time.

**Consumer**
A server that claims messages from the queue.

**Message**
A task, a notification, or any meaningful data that a producer or
publisher sends to the queue. A message exists until it is deleted by a
recipient or automatically by the system based on a TTL (time-to-live)
value.

**Message TTL**
Defines how long a message will be accessible.

**Producer**
A server or application that sends messages to the queue.

**Producer - Consumer**
A pattern where each worker application that reads the queue has to
claim the message in order to prevent duplicate processing. Later, when
work is done, the worker is responsible for deleting the message. If
message is not deleted in a predefined time, it can be claimed by other
workers.

**Publisher**
A server or application that posts messages to the queue with the intent
to distribute information or updates to multiple subscribers.

**Publisher - Subscriber**
A pattern where all worker applications have access to all messages in
the queue. Workers cannot delete or update messages.

**Queue**
The entity that holds messages. Ideally, a queue is created per work
type. For example, if you want to compress files, you would create a
queue dedicated to this job. Any application that reads from this queue
would only compress files.

**Subscriber**
An observer that watches messages like an RSS feed but does not claim
any messages.

**TTL**
Time-to-live value.

**Worker**
A client that claims messages from the queue and performs actions based
on those messages.