Skip to content

Commit 88deb76

Browse files
committed
Key concepts
1 parent b1e0bec commit 88deb76

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

‎docs/concepts.md‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Key concepts
2+
3+
If you are new to queuing system, there are some key concepts to understand to make the most of this lib.
4+
5+
## Messages and queues
6+
7+
The queue is where messages are sent to for later processing. Once in the queue, they wait to be fetched, processed and removed from the queue.
8+
A queue may provide the following features:
9+
- *receive and delete delivery*: the queue deletes the message when it's fetched. If processing fails, then the message is lost and won't be processed again. This is called _at most once_ processing.
10+
- *peek and lock delivery*: the queue locks for a short amount of time a message when it's fetched, making it invisible to other processes, in order to prevent duplicate processing. If there is no acknowledgment before the lock times out, failure is assumed and then the message is made visible again in the queue for another try. This is called _at least once_ processing.
11+
- *delayed or scheduled messages*: messages are sent to the queue but won't be visible right away to processes to fetch them. You may need it to plan an action at a specific time.
12+
- *first in first out*: messages are processed in the same order than they have entered the queue.
13+
14+
## Topic and subscription
15+
16+
These are are advanced features:
17+
- a message goes to a queue and is sent to multiple recipients
18+
- a message is routing to different queues depending on some rules
19+
20+
## Transport
21+
22+
The transport is the underlying vendor-specific system providing the queue features: most famous ones are RabbitMQ, Amazon SQS, ...
23+
Enqueue uses https://github.com/queue-interop/queue-interop PHP interfaces to provide a common way for programs to create, send, read messages in queues without worrying about vendor-specific internals.
24+
25+
## Destination
26+
27+
This is where a message goes, like a queue for a basic scenario but it may also be a topic or a command (understand a Symfony Console command).
28+
29+
## Connection factory, Driver and Context
30+
31+
The Connection factory creates a connection to the vendor service with vendor-specific config and theses are wrapped into a Context.
32+
The Context will then provides the Producer, the Consumer and helps creates Messages.
33+
34+
The Driver handles the routing of a Message.
35+
36+
## Producer & Consumer
37+
38+
The Producer sends the Message to the queue and the Consumer fetches Message from the queue.
39+
40+
Both the Producer and the Consumer implement vendor-specific logic and are in charge to convert messages between Enqueue common standard and vendor-specific message format.
41+
42+
## Processor
43+
44+
It handles the processing of the Message once received. It implements your business logic.
45+
46+
## Lifecycle
47+
48+
A queuing system is divided in two main parts: producing and consuming.
49+
50+
The [transport section of the Quick Start](quick_tour.md#transport) shows some code example for both parts.
51+
52+
### Producing part
53+
1. The application creates a Context with a Connection factory
54+
2. The Context helps the application to create a Message
55+
3. The application gets a Producer from the Context
56+
4. The application uses the Producer to send the Message to the queue
57+
58+
### Consuming part
59+
1. The application gets a Consumer from the Context
60+
2. The Consumer receives Messages from the queue
61+
3. The Consumer uses a Processor to process a Message
62+
4. The Processor returns a status (like `Interop\Queue\Processor::ACK`) to the Consumer
63+
5. The Consumer requeue or remove the Message from the queue depending on the Processor returned status
64+
65+
## How to use Enqueue?
66+
67+
There are different ways to use Enqueue: both reduce the boiler plate code you have to write to start using the Enqueue feature.
68+
- as a [Client](client/quick_tour.md): relies on a [DSN](client/supported_brokers.md) to connect
69+
- as a [Symfony Bundle](bundle/index.md): recommended if you are using the Symfony framework

‎docs/index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
1010
## Documentation.
1111

1212
* [Quick tour](quick_tour.md)
13+
* [Key concepts](concepts.md)
1314
* [Transports](#transports)
1415
- Amqp based on [the ext](transport/amqp.md), [bunny](transport/amqp_bunny.md), [the lib](transport/amqp_lib.md)
1516
- [Amazon SNS-SQS](transport/snsqs.md)

0 commit comments

Comments
 (0)