Skip to content

Commit 6b99418

Browse files
committed
Init commit.
0 parents  commit 6b99418

File tree

364 files changed

+31918
-0
lines changed

Some content is hidden

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

364 files changed

+31918
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*~
2+
/.idea/
3+
bin
4+
vendor

.php_cs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
$finder = Symfony\CS\Finder::create()
4+
->in(__DIR__)
5+
->notPath('vendor')
6+
;
7+
8+
return Symfony\CS\Config::create()
9+
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
10+
->fixers([
11+
'ordered_use',
12+
'no_blank_lines_before_namespace',
13+
'short_array_syntax',
14+
'unused_use',
15+
'phpdoc_order',
16+
17+
18+
])
19+
->finder($finder)
20+
;
21+

.travis.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
sudo: required
2+
3+
git:
4+
depth: 10
5+
6+
language: php
7+
8+
php:
9+
- '5.6'
10+
- '7.0'
11+
12+
services:
13+
- docker
14+
15+
cache:
16+
directories:
17+
- $HOME/.composer/cache
18+
19+
install:
20+
- sudo /etc/init.d/mysql stop
21+
- rm $HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
22+
- echo "memory_limit=2048M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
23+
- pkg/mq-amqp-ext/travis/build-php-amqp-ext
24+
- cd $TRAVIS_BUILD_DIR
25+
- composer self-update
26+
- composer update --prefer-source
27+
28+
script:
29+
- bin/phpunit --exclude-group=functional
30+
- bin/dev -bt

Dockerfile.dev

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM ubuntu:16.04
2+
3+
## libs
4+
RUN set -x && \
5+
apt-get update && \
6+
apt-get install -y --no-install-recommends wget curl openssl ca-certificates nano netcat && \
7+
apt-get install -y --no-install-recommends php php-mysql php-curl php-intl php-mbstring php-zip php-mcrypt php-xdebug php-bcmath php-xml php-amqp
8+
9+
## confis
10+
11+
# RUN rm -f /etc/php/7.0/cli/conf.d/*xdebug.ini
12+
13+
COPY ./docker/php/cli.ini /etc/php/7.0/cli/conf.d/1-dev_cli.ini
14+
COPY ./docker/bin/dev_entrypoiny.sh /usr/local/bin/entrypoint.sh
15+
RUN chmod u+x /usr/local/bin/entrypoint.sh
16+
17+
RUN mkdir -p /mqdev
18+
WORKDIR /mqdev
19+
20+
CMD /usr/local/bin/entrypoint.sh

Dockerfile.rabbitmq

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM rabbitmq:3-management
2+
3+
RUN apt-get update
4+
RUN apt-get install -y curl
5+
6+
RUN curl http://www.rabbitmq.com/community-plugins/v3.6.x/rabbitmq_delayed_message_exchange-0.0.1.ez > $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-0.0.1.ez
7+
RUN rabbitmq-plugins enable --offline rabbitmq_delayed_message_exchange
8+
RUN rabbitmq-plugins enable --offline rabbitmq_stomp
9+
10+
EXPOSE 61613

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2013 Oro, Inc
2+
Copyright (c) 2016 Kotliar Maksym
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is furnished
9+
to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
THE SOFTWARE.

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Message Queue. Development Repository
2+
3+
[![Gitter](https://badges.gitter.im/php-enqueue/enqueue-dev.svg)](https://gitter.im/php-enqueue/enqueue-dev?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4+
[![Build Status](https://travis-ci.org/php-enqueue/enqueue-dev.png?branch=master)](https://travis-ci.org/php-enqueue/enqueue-dev)
5+
6+
This is where all development happens. The repository provides a friendly environment for productive development, testing.
7+
8+
## Resources
9+
10+
* [Documentation](https://github.com/php-enqueue/enqueue-dev/blob/master/docs/index.md)
11+
* [Questions](https://gitter.im/php-enqueue/enqueue-dev)
12+
* [Issue Tracker](https://github.com/php-enqueue/enqueue-dev/issues)
13+
14+
## License
15+
16+
It is released under the [MIT License](LICENSE).

composer.json

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"name": "enqueue/dev-message-queue",
3+
"type": "project",
4+
"minimum-stability": "dev",
5+
"require": {
6+
"php": ">=5.6",
7+
"enqueue/psr-queue": "*",
8+
"enqueue/enqueue": "*",
9+
"enqueue/stomp": "*",
10+
"enqueue/amqp-ext": "*",
11+
"enqueue/enqueue-bundle": "*",
12+
"enqueue/job-queue": "*",
13+
"enqueue/test": "*"
14+
},
15+
"require-dev": {
16+
"phpunit/phpunit": "^5",
17+
"doctrine/doctrine-bundle": "~1.2",
18+
"symfony/monolog-bundle": "^2.8|^3",
19+
"symfony/browser-kit": "^2.8|^3",
20+
"symfony/expression-language": "^2.8|^3",
21+
"friendsofphp/php-cs-fixer": "^1"
22+
},
23+
"config": {
24+
"bin-dir": "bin"
25+
},
26+
"repositories": [
27+
{
28+
"type": "path",
29+
"url": "pkg/psr-queue"
30+
},
31+
{
32+
"type": "path",
33+
"url": "pkg/test"
34+
},
35+
{
36+
"type": "path",
37+
"url": "pkg/enqueue"
38+
},
39+
{
40+
"type": "path",
41+
"url": "pkg/stomp"
42+
},
43+
{
44+
"type": "path",
45+
"url": "pkg/amqp-ext"
46+
},
47+
{
48+
"type": "path",
49+
"url": "pkg/enqueue-bundle"
50+
},
51+
{
52+
"type": "path",
53+
"url": "pkg/job-queue"
54+
}
55+
]
56+
}

docker-compose.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
version: '2'
2+
services:
3+
dev:
4+
build: { context: ., dockerfile: Dockerfile.dev }
5+
depends_on:
6+
- rabbitmq
7+
- mysql
8+
volumes:
9+
- ./:/mqdev
10+
environment:
11+
- SYMFONY__RABBITMQ__HOST=rabbitmq
12+
- SYMFONY__RABBITMQ__USER=guest
13+
- SYMFONY__RABBITMQ__PASSWORD=guest
14+
- SYMFONY__RABBITMQ__VHOST=mqdev
15+
- SYMFONY__RABBITMQ__AMQP__PORT=5672
16+
- SYMFONY__RABBITMQ__STOMP__PORT=61613
17+
- SYMFONY__DB__DRIVER=pdo_mysql
18+
- SYMFONY__DB__HOST=mysql
19+
- SYMFONY__DB__PORT=3306
20+
- SYMFONY__DB__NAME=mqdev
21+
- SYMFONY__DB__USER=root
22+
- SYMFONY__DB__PASSWORD=rootpass
23+
24+
rabbitmq:
25+
build: { context: ., dockerfile: Dockerfile.rabbitmq }
26+
ports:
27+
- "15672:15672"
28+
environment:
29+
- RABBITMQ_DEFAULT_USER=guest
30+
- RABBITMQ_DEFAULT_PASS=guest
31+
- RABBITMQ_DEFAULT_VHOST=mqdev
32+
mysql:
33+
image: mariadb:10
34+
ports:
35+
- "3306:3306"
36+
volumes:
37+
- mysql-data:/var/lib/mysql
38+
environment:
39+
MYSQL_ROOT_PASSWORD: rootpass
40+
41+
volumes:
42+
mysql-data:
43+
driver: local

docker/php/cli.ini

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error_reporting=E_ALL
2+
display_errors=on
3+
memory_limit = 2G
4+
max_execution_time=0
5+
date.timezone=UTC
6+
variables_order="EGPCS"
7+
8+
extension=amqp.so

docs/amqp_transport.md

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# AMQP transport
2+
3+
* [Create context](#create-context)
4+
* [Declare topic](#declare-topic)
5+
* [Declare queue](#decalre-queue)
6+
* [Bind queue to topic](#bind-queue-to-topic)
7+
* [Send message to topic](#send-message-to-topic)
8+
* [Send message to queue](#send-message-to-queue)
9+
* [Consume message](#consume-message)
10+
11+
## Create context
12+
13+
```php
14+
<?php
15+
use Enqueue\AmqpExt\AmqpConnectionFactory;
16+
17+
$connectionFactory = new AmqpConnectionFactory([
18+
'host' => '127.0.0.1',
19+
'port' => 5672,
20+
'vhost' => '/',
21+
'login' => 'guest',
22+
'password' => 'guest',
23+
'persisted' => false,
24+
]);
25+
26+
$psrContext = $connectionFactory->createContext();
27+
```
28+
29+
## Declare topic.
30+
31+
Declare topic operation creates a topic on a broker side.
32+
33+
```php
34+
<?php
35+
/** @var \Enqueue\AmqpExt\AmqpContext $psrContext */
36+
37+
$fooTopic = $psrContext->createTopic('foo');
38+
$fooTopic->addFlag(AMQP_EX_TYPE_FANOUT);
39+
$psrContext->declareTopic($fooTopic);
40+
41+
// to remove topic use delete topic method
42+
//$psrContext->deleteTopic($fooTopic);
43+
```
44+
45+
## Declare queue.
46+
47+
Declare queue operation creates a queue on a broker side.
48+
49+
```php
50+
<?php
51+
/** @var \Enqueue\AmqpExt\AmqpContext $psrContext */
52+
53+
$fooQueue = $psrContext->createQueue('foo');
54+
$fooQueue->addFlag(AMQP_DURABLE);
55+
$psrContext->declareQueue($fooQueue);
56+
57+
// to remove topic use delete queue method
58+
//$psrContext->deleteQueue($fooQueue);
59+
```
60+
61+
## Bind queue to topic
62+
63+
Connects a queue to the topic. So messages from that topic comes to the queue and could be processed.
64+
65+
```php
66+
<?php
67+
/** @var \Enqueue\AmqpExt\AmqpContext $psrContext */
68+
/** @var \Enqueue\AmqpExt\AmqpQueue $fooQueue */
69+
/** @var \Enqueue\AmqpExt\AmqpTopic $fooTopic */
70+
71+
$psrContext->bind($fooTopic, $fooQueue);
72+
```
73+
74+
## Send message to topic
75+
76+
```php
77+
<?php
78+
/** @var \Enqueue\AmqpExt\AmqpContext $psrContext */
79+
/** @var \Enqueue\AmqpExt\AmqpTopic $fooTopic */
80+
81+
$message = $psrContext->createMessage('Hello world!');
82+
83+
$psrContext->createProducer()->send($fooTopic, $message);
84+
```
85+
86+
## Send message to queue
87+
88+
```php
89+
<?php
90+
/** @var \Enqueue\AmqpExt\AmqpContext $psrContext */
91+
/** @var \Enqueue\AmqpExt\AmqpQueue $fooQueue */
92+
93+
$message = $psrContext->createMessage('Hello world!');
94+
95+
$psrContext->createProducer()->send($fooQueue, $message);
96+
```
97+
98+
## Consume message:
99+
100+
```php
101+
<?php
102+
/** @var \Enqueue\AmqpExt\AmqpContext $psrContext */
103+
/** @var \Enqueue\AmqpExt\AmqpQueue $fooQueue */
104+
105+
$consumer = $psrContext->createConsumer($fooQueue);
106+
107+
$message = $consumer->receive();
108+
109+
// process a message
110+
111+
$consumer->acknowledge($message);
112+
// $consumer->reject($message);
113+
```
114+
115+
[back to index](index.md)

docs/bundle/debuging.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Debugging
2+
3+
[back to index](../index.md)

0 commit comments

Comments
 (0)