Skip to content

Commit 8a883ea

Browse files
authored
Merge pull request #1949 from greg-ab/patch-1
[Docs] Update doc related to use of fos:elastica:populate command with SQS
2 parents e5c76f3 + 20568c3 commit 8a883ea

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

doc/cookbook/speed-up-populate-command-sqs.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,30 @@ $ composer require enqueue/elastica-bundle
1616
$ composer require enqueue/sqs
1717
```
1818

19-
Define a handful of useful entries in `parameters.yml`
19+
Add the useful variables to your parameters, usually defined in `services.yaml` :
2020

2121
```yaml
2222
parameters:
23-
aws_sqs_key: XXXXX
24-
aws_sqs_secret_key: XXXXX
25-
aws_sqs_region: XXXXX
26-
aws_sqs_queue_name: XXXXX
27-
aws_sqs_reply_queue_name: XXXXX
23+
aws_sqs_key: '%env(AWS_SQS_KEY)%'
24+
aws_sqs_secret_key: '%env(AWS_SQS_SECRET_KEY)%'
25+
aws_sqs_region: '%env(AWS_SQS_REGION)%'
26+
aws_sqs_queue_name: '%env(AWS_SQS_QUEUE_NAME)%'
27+
aws_sqs_reply_queue_name: '%env(AWS_SQS_REPLY_QUEUE_NAME)%'
2828
```
2929
30-
Your `vendor/enqueue.yml` config should look like, taking three of the parameters defined above.
30+
You will need to define the corresponding environment variables for a later use.
31+
32+
Your `config/packages/enqueue.yml` config should look like, taking three of the parameters defined above.
3133

3234
```yaml
3335
enqueue:
34-
transport:
35-
default: sqs
36-
sqs:
37-
key: "%aws_sqs_key%"
38-
secret: "%aws_sqs_secret_key%"
39-
region: "%aws_sqs_region%"
36+
default:
37+
transport:
38+
dsn: 'sqs:?key=%aws_sqs_key%&secret=%aws_sqs_secret_key%&region=%aws_sqs_region%'
39+
client: ~
4040
4141
enqueue_elastica:
42+
transport: '%enqueue.default_transport%'
4243
doctrine: ~
4344
```
4445

@@ -52,13 +53,13 @@ services:
5253
$queueName: "%aws_sqs_queue_name%"
5354
$replyQueueName: "%aws_sqs_reply_queue_name%"
5455
tags:
55-
- { name: kernel.event_listener, event: elastica.pager_persister.pre_persist, method: prePersist }
56+
- { name: kernel.event_listener, method: prePersist }
5657
```
5758

58-
Here is a simple implementation of `QueuePagerPersister` that is aware of AWS, again it takes the parameters you defined above.
59+
Here is a simple implementation of `QueuePagerPersister` that is aware of AWS, and takes the parameters you defined above.
5960

6061
```php
61-
namespace AppBundle\Listener;
62+
namespace App\Listener;
6263
6364
use FOS\ElasticaBundle\Persister\Event\PrePersistEvent;
6465
@@ -130,7 +131,7 @@ Go the AWS GUI console and you should see the messages added to the queue. If yo
130131
The messages are now in the AWS SQS queue, ready to be consumed.
131132

132133
```bash
133-
php bin/console enqueue:transport:consume enqueue_elastica.populate_processor --queue=acme_fos_elastica_populate -vv
134+
php bin/console enqueue:transport:consume enqueue_elastica.populate_processor <queue_name> -vvv
134135
[info] Start consuming
135136
[info] Message received from the queue: acme_fos_elastica_populate
136137
[info] Message processed: enqueue.ack
@@ -139,6 +140,9 @@ php bin/console enqueue:transport:consume enqueue_elastica.populate_processor --
139140
...
140141
```
141142

143+
| `<queue_name>` should be replaced with the name defined as `AWS_SQS_QUEUE_NAME` (not the reply queue)
144+
145+
142146
You should now start seeing the progress increase with the fos:elastica:populate, when all the messages are consumed you should get a brand new and re-populated index.
143147

144148
```bash

0 commit comments

Comments
 (0)