File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change
1
+ # Consumption extension
2
+
3
+ Here, I show how you can crate a custom extension and register it.
4
+ Let's first create an extension itself:
5
+
6
+ ``` php
7
+ <?php
8
+ // src/AppBundle/Enqueue;
9
+ namespace AppBundle\Enqueue;
10
+
11
+ use Enqueue\Consumption\ExtensionInterface;
12
+ use Enqueue\Consumption\EmptyExtensionTrait;
13
+ use Enqueue\Consumption\Context;
14
+
15
+ class CountProcessedMessagesExtension implements ExtensionInterface
16
+ {
17
+ use EmptyExtensionTrait;
18
+
19
+ private $processedMessages = 0;
20
+
21
+ /**
22
+ * {@inheritdoc}
23
+ */
24
+ public function onPostReceived(Context $context)
25
+ {
26
+ $this->processedMessages += 1;
27
+ }
28
+ }
29
+ ```
30
+
31
+ Now we have to register as a Symfony service with special tag:
32
+
33
+ ``` yaml
34
+ services :
35
+ app.enqueue.count_processed_messages_extension :
36
+ class : ' AppBundle\Enqueue\CountProcessedMessagesExtension'
37
+ tags :
38
+ - { name: 'enqueue.consumption.extension', priority: 10 }
39
+ ` ` `
40
+
41
+ [back to index](../index.md)
Original file line number Diff line number Diff line change 1
1
# Consumption extensions.
2
2
3
-
3
+ You can learn how to register extensions in [ quick tour] ( ../quick_tour.md#consumption ) .
4
+ There's dedicated [ chapter] ( ../bundle/consumption_extension.md ) for how to add extension in Symfony app.
4
5
5
6
## [ LoggerExtension] ( https://github.com/php-enqueue/enqueue-dev/blob/master/pkg/enqueue/Consumption/Extension/LoggerExtension.php )
6
7
Original file line number Diff line number Diff line change 12
12
- [ Config reference] ( bundle/config_reference.md )
13
13
- [ Cli commands] ( bundle/cli_commands.md )
14
14
- [ Job queue] ( bundle/job_queue.md )
15
+ - [ Consumption extension] ( bundle/consumption_extension.md )
15
16
- [ Production settings] ( bundle/production_settings.md )
16
17
- [ Debuging] ( bundle/debuging.md )
17
18
- [ Functional testing] ( bundle/functional_testing.md )
You can’t perform that action at this time.
0 commit comments