Skip to content

Commit e5d5910

Browse files
authored
Merge branch 'master' into symfony4
2 parents e75a28e + 5359649 commit e5d5910

20 files changed

Lines changed: 611 additions & 49 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/docs/_build
44
/coverage
55
.idea
6+
/nbproject

.travis.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,17 @@ cache:
77
- $HOME/.composer/cache/files
88

99
php:
10-
- 5.4
11-
- 5.5
1210
- hhvm
13-
11+
1412
matrix:
1513
fast_finish: true
1614
include:
17-
- php: 5.6
18-
env: SYMFONY_VERSION=2.3.*
19-
- php: 5.6
20-
env: SYMFONY_VERSION=2.6.*
2115
- php: 5.6
2216
env: SYMFONY_VERSION=2.7.*
2317
- php: 5.6
2418
env: SYMFONY_VERSION=2.8.*
19+
- php: 5.6
20+
env: SYMFONY_VERSION=3.4.*
2521
- php: 7.0
2622
env: COVERAGE=yes
2723
allow_failures:
@@ -36,7 +32,7 @@ install:
3632
- composer install --prefer-dist
3733

3834
script:
39-
- if [ "$COVERAGE" = "yes" ]; then phpunit --coverage-text --coverage-clover=coverage.clover --testsuite "UecodeQPushBundle Test Suite"; else phpunit --testsuite "UecodeQPushBundle Test Suite"; fi
35+
- if [ "$COVERAGE" = "yes" ]; then ./vendor/bin/simple-phpunit --coverage-text --coverage-clover=coverage.clover --testsuite "UecodeQPushBundle Test Suite"; else ./vendor/bin/simple-phpunit --testsuite "UecodeQPushBundle Test Suite"; fi
4036

4137
after_script:
4238
- if [ "$COVERAGE" = "yes" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ QPush - Symfony2 Push Queue Bundle
66
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/uecode/qpush-bundle.svg?style=flat-square)](https://scrutinizer-ci.com/g/uecode/qpush-bundle/)
77
[![Total Downloads](http://img.shields.io/packagist/dt/uecode/qpush-bundle.svg?style=flat-square)](https://packagist.org/packages/uecode/qpush-bundle)
88

9-
##Overview
9+
## Overview
1010
This bundle allows you to easily consume messages from Push Queues by simply
1111
tagging your services and relying on Symfony's event dispatcher - without
1212
needing to run a daemon or background process to continuously poll your queue.
@@ -158,4 +158,3 @@ public function onMessageReceived(MessageEvent $event)
158158

159159
Once all other Event Listeners have been invoked on a `MessageEvent`, the Bundle
160160
will automatically attempt to remove the Message from your Queue for you.
161-

composer.json

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,31 @@
1717
"email": "kkirk@undergroundelephant.com"
1818
},
1919
"require": {
20-
"php": ">=5.4.0",
21-
"doctrine/common": "~2.4",
20+
"php": ">=5.6.0",
21+
"doctrine/common": "~2.4",
2222
"symfony/dependency-injection": "~2.3|^3.0|^4.0",
2323
"symfony/config": "~2.3|^3.0",
2424
"symfony/http-kernel": "~2.3|^3.0|^4.0",
2525
"symfony/console": "~2.3|^3.0|^4.0",
26-
"symfony/monolog-bundle": "~2.3|^3.0|^4.0"
26+
"symfony/monolog-bundle": "~2.3|^3.0|^4.0"
2727
},
2828
"require-dev": {
29-
"phpunit/phpunit": "~3.7",
30-
"aws/aws-sdk-php": "~2.5",
31-
"iron-io/iron_mq": "^4.0",
32-
"symfony/finder": "~2.3|^3.0|^4.0",
33-
"symfony/filesystem": "~2.3|^3.0|^4.0"
29+
"aws/aws-sdk-php": "~2.5",
30+
"iron-io/iron_mq": "^4.0",
31+
"symfony/finder": "~2.3|^3.0|^4.0",
32+
"symfony/filesystem": "~2.3|^3.0|^4.0",
33+
"symfony/phpunit-bridge": "^4.0",
34+
"symfony/yaml": "~2.8|^3.0|^4.0",
35+
"doctrine/orm": "^2.4.8",
36+
"stof/doctrine-extensions-bundle": "^1.2"
3437
},
3538
"suggest": {
3639
"aws/aws-sdk-php": "Required to use AWS as a Queue Provider",
3740
"iron-io/iron_mq": "Required to use IronMQ as a Queue Provider",
3841
"symfony/finder": "Required to use File as a Queue Provider",
39-
"symfony/filesystem": "Required to use File as a Queue Provider"
42+
"symfony/filesystem": "Required to use File as a Queue Provider",
43+
"doctrine/orm": "Required to use Doctrine as a Queue Provider",
44+
"stof/doctrine-extensions-bundle": "Required to use Doctrine as a Queue Provider"
4045
},
4146
"autoload": {
4247
"psr-4": {

docs/configuration.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ A working configuration would look like the following
152152
provider: aws
153153
options:
154154
queue_name: my_actual_queue_name.fifo
155-
push_notifications: true
155+
push_notifications: false
156156
notification_retries: 3
157157
message_delay: 0
158158
message_timeout: 30
@@ -164,3 +164,5 @@ A working configuration would look like the following
164164
subscribers:
165165
- { endpoint: http://example1.com/, protocol: http }
166166
- { endpoint: http://example2.com/, protocol: http }
167+
168+
Note that `FIFO` queues are not currently compatible with `push_notifications`. For more information, see: http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-subscribe-queue-sns-topic.html

src/Command/QueueReceiveCommand.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ private function pollQueue($registry, $name)
100100
$dispatcher = $this->container->get('event_dispatcher');
101101
$messages = $registry->get($name)->receive();
102102

103-
foreach ($messages as $message) {
104-
$messageEvent = new MessageEvent($name, $message);
105-
$dispatcher->dispatch(Events::Message($name), $messageEvent);
103+
if($messages) {
104+
foreach ($messages as $message) {
105+
$messageEvent = new MessageEvent($name, $message);
106+
$dispatcher->dispatch(Events::Message($name), $messageEvent);
107+
}
106108
}
107109

108110
$msg = "<info>Finished polling %s Queue, %d messages fetched.</info>";

src/DependencyInjection/Configuration.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ private function getProvidersNode()
6161
'ironmq' => ['token', 'project_id'],
6262
'sync' => [],
6363
'custom' => ['service'],
64-
'file' => ['path']
64+
'file' => ['path'],
65+
'doctrine' => []
6566
];
6667

6768
$node
@@ -98,6 +99,10 @@ private function getProvidersNode()
9899
->end()
99100
// File
100101
->scalarNode('path')->end()
102+
// Doctrine
103+
->scalarNode('entity_manager')
104+
->defaultValue('doctrine.orm.default_entity_manager')
105+
->end()
101106
->end()
102107

103108
->validate()

src/DependencyInjection/UecodeQPushExtension.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,18 @@ public function load(array $configs, ContainerBuilder $container)
9898
$class = $container->getParameter('uecode_qpush.provider.file');
9999
$values['options']['path'] = $config['providers'][$provider]['path'];
100100
break;
101+
case 'doctrine':
102+
$class = $container->getParameter('uecode_qpush.provider.doctrine');
103+
$client = $this->createDoctrineClient($config['providers'][$provider]);
104+
break;
101105
}
102106

103107
$definition = new Definition(
104108
$class, [$queue, $values['options'], $client, new Reference($cache), new Reference('logger')]
105109
);
106110

111+
$definition->setPublic(true);
112+
107113
$definition->addTag('monolog.logger', ['channel' => 'qpush'])
108114
->addTag(
109115
'uecode_qpush.event_listener',
@@ -254,6 +260,11 @@ private function createSyncClient()
254260
{
255261
return new Reference('event_dispatcher');
256262
}
263+
264+
private function createDoctrineClient($config)
265+
{
266+
return new Reference($config['entity_manager']);
267+
}
257268

258269
/**
259270
* @param string $serviceId

0 commit comments

Comments
 (0)