Skip to content

Commit 370eb67

Browse files
committed
Merge branch 'master' into 0.9
2 parents edad64d + 5bd31c2 commit 370eb67

58 files changed

Lines changed: 624 additions & 217 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
# Change Log
22

3+
## [0.8.21](https://github.com/php-enqueue/enqueue-dev/tree/0.8.21) (2018-02-16)
4+
[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.8.20...0.8.21)
5+
6+
- \[symfony\] Print command name [\#374](https://github.com/php-enqueue/enqueue-dev/pull/374) ([makasim](https://github.com/makasim))
7+
8+
- Delayed-message doesn't work on my project ! [\#373](https://github.com/php-enqueue/enqueue-dev/issues/373)
9+
- \[Symfony\] Command name misses in profiler [\#355](https://github.com/php-enqueue/enqueue-dev/issues/355)
10+
11+
## [0.8.20](https://github.com/php-enqueue/enqueue-dev/tree/0.8.20) (2018-02-15)
12+
[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.8.19...0.8.20)
13+
14+
- \[Redis\] Add ability to pass Redis instance to connection factory [\#372](https://github.com/php-enqueue/enqueue-dev/pull/372) ([makasim](https://github.com/makasim))
15+
16+
- Pass options to predis client when using redis transport [\#367](https://github.com/php-enqueue/enqueue-dev/issues/367)
17+
- Authentication Support for Redis [\#349](https://github.com/php-enqueue/enqueue-dev/issues/349)
18+
- Does redis factory supports sentinel or cluster? [\#341](https://github.com/php-enqueue/enqueue-dev/issues/341)
19+
20+
## [0.8.19](https://github.com/php-enqueue/enqueue-dev/tree/0.8.19) (2018-02-14)
21+
[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.8.18...0.8.19)
22+
23+
- \[Docs\] Describe difference between command and event messages [\#351](https://github.com/php-enqueue/enqueue-dev/issues/351)
24+
- Fix typo [\#369](https://github.com/php-enqueue/enqueue-dev/pull/369) ([kubk](https://github.com/kubk))
25+
- \[client\]\[skip ci\] Explain meaning of sendEvent, sendCommand methods. [\#365](https://github.com/php-enqueue/enqueue-dev/pull/365) ([makasim](https://github.com/makasim))
26+
- Modify async\_events.md grammar [\#364](https://github.com/php-enqueue/enqueue-dev/pull/364) ([ddproxy](https://github.com/ddproxy))
27+
28+
- Fix wrong argument type [\#361](https://github.com/php-enqueue/enqueue-dev/pull/361) ([olix21](https://github.com/olix21))
29+
30+
- Minor grammatical changes to documentation [\#363](https://github.com/php-enqueue/enqueue-dev/issues/363)
31+
- \[DbalConsumer\] Issue with id type [\#360](https://github.com/php-enqueue/enqueue-dev/issues/360)
32+
33+
- \[dbal\] Sort priority messages by published at date too. [\#371](https://github.com/php-enqueue/enqueue-dev/pull/371) ([makasim](https://github.com/makasim))
34+
335
## [0.8.18](https://github.com/php-enqueue/enqueue-dev/tree/0.8.18) (2018-02-07)
436
[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.8.17...0.8.18)
537

‎bin/dev‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ set -e
66
while getopts "bustefcdp" OPTION; do
77
case $OPTION in
88
b)
9-
COMPOSE_PROJECT_NAME=mqdev docker-compose pull && COMPOSE_PROJECT_NAME=mqdev docker-compose build
9+
docker-compose pull && docker-compose build
1010
;;
1111
u)
12-
COMPOSE_PROJECT_NAME=mqdev docker-compose up
12+
docker-compose up
1313
;;
1414
s)
15-
COMPOSE_PROJECT_NAME=mqdev docker-compose stop
15+
docker-compose stop
1616
;;
1717
e)
1818
docker exec -it mqdev_dev_1 /bin/bash
@@ -24,10 +24,10 @@ while getopts "bustefcdp" OPTION; do
2424
./bin/run-fun-test.sh "$2"
2525
;;
2626
c)
27-
COMPOSE_PROJECT_NAME=mqdev docker-compose run -e CHANGELOG_GITHUB_TOKEN=${CHANGELOG_GITHUB_TOKEN:-""} --workdir="/mqdev" --rm generate-changelog github_changelog_generator --future-release "$2" --simple-list
27+
docker-compose run -e CHANGELOG_GITHUB_TOKEN=${CHANGELOG_GITHUB_TOKEN:-""} --workdir="/mqdev" --rm generate-changelog github_changelog_generator --future-release "$2" --simple-list
2828
;;
2929

30-
d) COMPOSE_PROJECT_NAME=mqdev docker-compose run --workdir="/mqdev" --rm dev php pkg/enqueue-bundle/Tests/Functional/app/console.php config:dump-reference enqueue -vvv
30+
d) docker-compose run --workdir="/mqdev" --rm dev php pkg/enqueue-bundle/Tests/Functional/app/console.php config:dump-reference enqueue -vvv
3131
;;
3232
\?)
3333
echo "Invalid option: -$OPTARG" >&2

‎docs/bundle/async_events.md‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,24 @@ The consumer, once it receives the message, restores the event and dispatches it
77

88
Async listeners benefits:
99

10-
* The response time lesser. It has to do less work.
11-
* Better fault tolerance. Bugs in async listener does not affect user. Messages will wait till you fix bugs.
10+
* Reduces response time. Work is deferred to consumer processes.
11+
* Better fault tolerance. Bugs in async listener do not affect user. Messages will wait till you fix bugs.
1212
* Better scaling. Add more consumers to meet the load.
1313

14-
_**Note**: The php serializer transformer (the default one) does not work on Symfony prior 3.0. The event contains eventDispatcher and therefor could not be serialized. You have to register a transformer for every async event. Read the [event transformer](#event-transformer)._
14+
_**Note**: Prior to Symfony 3.0, events contain `eventDispatcher` and the default php serializer transformer is unable to serialize the object. A transformer should be registered for every async event. Read the [event transformer](#event-transformer)._
1515

1616
## Configuration
1717

18-
I suppose you already [installed the bundle](quick_tour.md#install).
19-
Now, you have to enable `async_events`.
20-
If you do not enable it, events will be processed as before: synchronously.
18+
Symfony events are currently processed synchronously, enabling the async configuration for EnqueueBundle causes tagged listeners to defer action to a consumer asynchronously.
19+
If you already [installed the bundle](quick_tour.md#install), then enable `async_events`.
2120

2221
```yaml
2322
# app/config/config.yml
2423

2524
enqueue:
2625
async_events:
2726
enabled: true
28-
# if you'd like to send send messages onTerminate use spool_producer (it makes response time even lesser):
27+
# if you'd like to send send messages onTerminate use spool_producer (it further reduces response time):
2928
# spool_producer: true
3029
```
3130

@@ -77,7 +76,7 @@ services:
7776
## Event transformer
7877

7978
The bundle uses [php serializer](https://github.com/php-enqueue/enqueue-dev/blob/master/pkg/enqueue-bundle/Events/PhpSerializerEventTransformer.php) transformer by default to pass events through MQ.
80-
You could create a transformer for the given event type. The transformer must implement `Enqueue\AsyncEventDispatcher\EventTransformer` interface.
79+
You can write a transformer for each event type by implementing the `Enqueue\AsyncEventDispatcher\EventTransformer` interface.
8180
Consider the next example. It shows how to send an event that contains Doctrine entity as a subject
8281

8382
```php
@@ -165,4 +164,4 @@ services:
165164
The `eventName` attribute accepts a regexp. You can do next `eventName: '/foo\..*?/'`.
166165
It uses this transformer for all event with the name beginning with `foo.`
167166

168-
[back to index](../index.md)
167+
[back to index](../index.md)

‎docs/bundle/debuging.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ Here's the result:
6363

6464
## Consume command verbosity
6565

66-
By default the commands `enqueu:conume` or `enqueue:transport:consume` does not output anything.
66+
By default the commands `enqueue:consume` or `enqueue:transport:consume` does not output anything.
6767
You can add `-vvv` to see more information.
6868

6969
![Consume command verbosity](../images/consume_command_verbosity.png)
7070

71-
[back to index](../index.md)
71+
[back to index](../index.md)

‎docs/client/quick_tour.md‎

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ $ composer require enqueue/simple-client enqueue/amqp-ext
1616

1717
## Configure
1818

19+
The code below shows how to use simple client with AMQP transport. There are other [supported brokers](supported_brokers.md).
20+
1921
```php
2022
<?php
2123
use Enqueue\SimpleClient\SimpleClient;
@@ -27,25 +29,56 @@ $client = new SimpleClient('amqp:');
2729

2830
## Produce message
2931

32+
There two types of message a client can produce: events and commands.
33+
Events are used to notify others about something, in other words it is an implementation of [publish-subscribe pattern](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern), sometimes called "fire-and-forget" too.
34+
With events there is no way to get a reply as a producer is not aware of any subscribed consumers.
35+
Commands are used to request a job to be done. It is an implementation of one-to-one messaging pattern.
36+
A producer can request a reply from the consumer though it is up to the consumer whether send it or not.
37+
38+
Commands work inside the app [scope](message_examples.md#scope) where events work inside the app scope as well as on [message bus](message_bus.md) scope.
39+
40+
Send event examples:
41+
3042
```php
3143
<?php
3244

3345
/** @var \Enqueue\SimpleClient\SimpleClient $client */
3446

35-
$client->send('a_bar_topic', 'aMessageData');
47+
$client->setupBroker();
48+
49+
$client->sendEvent('user_updated', 'aMessageData');
3650

3751
// or an array
3852

39-
$client->send('a_bar_topic', ['foo', 'bar']);
53+
$client->sendEvent('order_price_calculated', ['foo', 'bar']);
4054

4155
// or an json serializable object
42-
$client->send('a_bar_topic', new class() implements \JsonSerializable {
56+
$client->sendEvent('user_activated', new class() implements \JsonSerializable {
4357
public function jsonSerialize() {
4458
return ['foo', 'bar'];
4559
}
4660
});
4761
```
4862

63+
Send command examples:
64+
65+
```php
66+
<?php
67+
68+
/** @var \Enqueue\SimpleClient\SimpleClient $client */
69+
70+
$client->setupBroker();
71+
72+
// accepts same type of arguments as sendEvent method
73+
$client->sendCommand('calculate_statistics', 'aMessageData');
74+
75+
$reply = $client->sendCommand('build_category_tree', 'aMessageData', true);
76+
77+
$replyMessage = $reply->receive(5000); // wait for reply for 5 seconds
78+
79+
$replyMessage->getBody();
80+
```
81+
4982
## Consume messages
5083

5184
```php

‎docs/client/supported_brokers.md‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Client. Supported brokers
22

3+
Here's the list of transports supported by Enqueue Client:
4+
5+
| Transport | Package | DSN |
6+
|:-------------------:|:----------------------------------------------------------:|:-------------------------------:|
7+
| AMQP, RabbitMQ | [enqueue/amqp-bunny](../transport/amqp_bunny.md) | amqp: amqp+bunny: |
8+
| AMQP, RabbitMQ | [enqueue/amqp-lib](../transport/amqp_lib.md) | amqp: amqp+lib: |
9+
| AMQP, RabbitMQ | [enqueue/amqp-ext](../transport/amqp.md) | amqp: amqp+ext: |
10+
| Doctrine DBAL | [enqueue/dbal](../transport/dbal.md) | mysql: pgsql: pdo_pgsql etc |
11+
| Filesystem | [enqueue/fs](../transport/fs.md) | file:///foo/bar |
12+
| Google PubSub | [enqueue/gps](../transport/gps.md) | gps: |
13+
| Redis | [enqueue/gps](../transport/redis.md) | redis: |
14+
| Amazon SQS | [enqueue/sqs](../transport/sqs.md) | sqs: |
15+
| STOMP, RabbitMQ | [enqueue/stomp](../transport/stomp.md) | stomp: |
16+
| Null | [enqueue/null](../transport/null.md) | null: |
17+
318
Here's the list of protocols and Client features supported by them
419

520
| Protocol | Priority | Delay | Expiration | Setup broker | Message bus |
@@ -11,7 +26,8 @@ Here's the list of protocols and Client features supported by them
1126
| Filesystem | No | No | No | Yes | No |
1227
| Redis | No | No | No | Not needed | No |
1328
| Doctrine DBAL | Yes | Yes | No | Yes | No |
14-
| AWS SQS | No | Yes | No | Yes | Not impl |
29+
| Amazon SQS | No | Yes | No | Yes | Not impl |
30+
| Google PubSub | Not impl | Not impl | Not impl | Yes | Not impl |
1531

1632
* \* Possible if a RabbitMQ delay plugin is installed.
1733
* \*\* Possible if topics (exchanges) are configured on broker side manually.

‎docs/quick_tour.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ $replyMessage = $promise->receive(2000); // 2 sec
233233
$client->consume([new ReplyExtension()]);
234234
```
235235

236+
Read more about events and commands [here](client/quick_tour.md#produce-message).
237+
236238
## Cli commands
237239

238240
The library provides handy commands out of the box.

‎docs/transport/redis.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ $connectionFactory = new RedisConnectionFactory([
7878
$psrContext = $connectionFactory->createContext();
7979
```
8080

81+
* With custom redis instance:
82+
83+
It gives you more control over vendor specific features.
84+
85+
```php
86+
<?php
87+
use Enqueue\Redis\RedisConnectionFactory;
88+
use Enqueue\Redis\PRedis;
89+
90+
$config = [];
91+
$options = [];
92+
93+
$redis = new PRedis(new \PRedis\Client($config, $options));
94+
95+
$factory = new RedisConnectionFactory(['vendor' => 'custom', 'redis' => $redis]);
96+
```
97+
8198
## Send message to topic
8299

83100
```php

‎pkg/amqp-bunny/AmqpContext.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public function bind(InteropAmqpBind $bind)
249249
(bool) ($bind->getFlags() & InteropAmqpBind::FLAG_NOWAIT),
250250
$bind->getArguments()
251251
);
252-
// bind queue to exchange
252+
// bind queue to exchange
253253
} elseif ($bind->getSource() instanceof InteropAmqpQueue) {
254254
$this->getBunnyChannel()->queueBind(
255255
$bind->getSource()->getQueueName(),
@@ -258,7 +258,7 @@ public function bind(InteropAmqpBind $bind)
258258
(bool) ($bind->getFlags() & InteropAmqpBind::FLAG_NOWAIT),
259259
$bind->getArguments()
260260
);
261-
// bind exchange to queue
261+
// bind exchange to queue
262262
} else {
263263
$this->getBunnyChannel()->queueBind(
264264
$bind->getTarget()->getQueueName(),
@@ -288,15 +288,15 @@ public function unbind(InteropAmqpBind $bind)
288288
(bool) ($bind->getFlags() & InteropAmqpBind::FLAG_NOWAIT),
289289
$bind->getArguments()
290290
);
291-
// bind queue to exchange
291+
// bind queue to exchange
292292
} elseif ($bind->getSource() instanceof InteropAmqpQueue) {
293293
$this->getBunnyChannel()->queueUnbind(
294294
$bind->getSource()->getQueueName(),
295295
$bind->getTarget()->getTopicName(),
296296
$bind->getRoutingKey(),
297297
$bind->getArguments()
298298
);
299-
// bind exchange to queue
299+
// bind exchange to queue
300300
} else {
301301
$this->getBunnyChannel()->queueUnbind(
302302
$bind->getTarget()->getQueueName(),

‎pkg/amqp-bunny/AmqpProducer.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ public function setDeliveryDelay($deliveryDelay)
8989
}
9090

9191
$this->deliveryDelay = $deliveryDelay;
92+
93+
return $this;
9294
}
9395

9496
/**

0 commit comments

Comments
 (0)