Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6c34b77

Browse files
committed
Merge branch 'master' into pr-362
2 parents d21c8ac + 4064f07 commit 6c34b77

File tree

10 files changed

+75
-18
lines changed

10 files changed

+75
-18
lines changed

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.

pkg/dbal/DbalConsumer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ protected function receiveMessage()
155155

156156
// remove message
157157
$affectedRows = $this->dbal->delete($this->context->getTableName(), ['id' => $dbalMessage['id']], [
158-
'id' => Type::INTEGER,
158+
'id' => Type::GUID,
159159
]);
160160

161161
if (1 !== $affectedRows) {

pkg/dbal/DbalProducer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function send(PsrDestination $destination, PsrMessage $message)
8383

8484
$dbalMessage = [
8585
'id' => $uuid,
86-
'published_at' => (int) microtime(true) * 10000,
86+
'published_at' => (int) (microtime(true) * 10000),
8787
'body' => $body,
8888
'headers' => JSON::encode($message->getHeaders()),
8989
'properties' => JSON::encode($message->getProperties()),

pkg/enqueue/composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@
6060
"/Tests/"
6161
]
6262
},
63+
"config": {
64+
"platform": {
65+
"ext-amqp": "1.9.3"
66+
}
67+
},
6368
"minimum-stability": "dev",
6469
"extra": {
6570
"branch-alias": {

pkg/job-queue/.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cache:
1515

1616
install:
1717
- composer self-update
18-
- composer install --prefer-source
18+
- travis_retry composer install --prefer-dist
1919

2020
script:
2121
- vendor/bin/phpunit --exclude-group=functional

pkg/simple-client/SimpleClient.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ public function sendEvent($topic, $message)
125125
}
126126

127127
/**
128+
* @deprecated since 0.8.18 and will be removed in 0.9. Use sendEvent method instead
129+
*
128130
* @param string $topic
129131
* @param string|array $message
130132
* @param bool $setupBroker

0 commit comments

Comments
 (0)