Skip to content
This repository has been archived by the owner on Jan 17, 2022. It is now read-only.

Commit

Permalink
docs(messenger): Add documentation about Symfony Messenger integration (
Browse files Browse the repository at this point in the history
  • Loading branch information
k911 authored Aug 11, 2019
1 parent f0c2b73 commit 37d18bc
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ Symfony integration with [Swoole](https://www.swoole.co.uk/) to speed up your ap

Since Swoole HTTP Server runs in Event Loop and do not flush memory between requests, to keep DX equal with normal servers, this bundle uses code replacement techinque, using `inotify` PHP Extension to allow contionus development. It is enabled by default (when extension is found), and requires no additional configuration. You can turn it off in bundle configuration.

- Symfony Messenger integration

*Available since version: `0.6`*

Swoole Server Task Transport has been integrated into this bundle to allow easy execution of asynchronous actions. Documentation of this feature is available [here](docs/swoole-task-symfony-messenger-transport.md).

## Requirements

- PHP version `>= 7.2.19`
Expand Down
4 changes: 3 additions & 1 deletion docs/configuration-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

Documentation of available configuration parameters. See also symfony [bundle configuration](./../src/Bridge/Symfony/Bundle/DependencyInjection/Configuration.php) file or [swoole documentation](https://github.com/swoole/swoole-docs/tree/master/modules).

- [HTTP Server](#http-server)
- [Swoole Bundle Configuration](#swoole-bundle-configuration)
- [HTTP Server](#http-server)

## HTTP Server

Expand Down Expand Up @@ -73,6 +74,7 @@ swoole:
reactor_count: 2
worker_count: 4
# when not set, swoole sets these are automatically set based on count of host CPU cores
task_worker_count: 2 # one of: positive number, "auto", or null to disable creation of task worker processes (default: null)

log_level: auto
# can be one of: (default) auto, debug, trace, info, notice, warning, error
Expand Down
43 changes: 43 additions & 0 deletions docs/swoole-task-symfony-messenger-transport.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Swoole Server Task Transport (Symfony Messenger)

## Usage

1. Make sure you've enabled task workers in Swoole server

```yaml
# config/packages/swoole.yaml
swoole:
http_server:
settings:
task_worker_count: auto
```
2. Install `symfony/messenger` package in your application

```sh
composer require symfony/messenger
```

3. Configure Swoole Transport

```yaml
# config/packages/messenger.yaml
framework:
messenger:
transports:
swoole: swoole://task
routing:
'*': swoole
```

4. Now follow official Symfony Messenger guide to create messages, handlers and optionally different transports.

https://symfony.com/doc/current/messenger.html

## Example

You can also clone and play with [`swoole-bundle-symfony-demo`](https://github.com/k911/swoole-bundle-symfony-demo), where everything including Symfony Messenger configuration is set-up properly. You can run it in seconds using Docker!

## Implementation Notes

Swoole Task Transport always execute tasks / messages on the same Swoole HTTP Server instance, so before using it on production make sure you don't need to share persist/messages between different hosts without using external queue system like RabbitMQ. However, this transport should be convinenent to use for testing / local/development environments or on non-critical production workloads due to its simplicity. Also, keep in note that messages are passed between server processes without any serialization process, so unlike to **AMPQ** transport it is **NOT** required to implement `\Serializable` interface on your messages or include `symfony/serializer` package.

0 comments on commit 37d18bc

Please sign in to comment.