Skip to content

Commit 91bd73b

Browse files
author
Mikhail Bakulin
committed
Error verbosity increased and example application added
1 parent 2cd4bea commit 91bd73b

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Configuration extends Component
4242
'ssl_context' => null,
4343
'keepalive' => false,
4444
'heartbeat' => 0,
45-
'channel_rpc_timeout' => 0.0
45+
'channel_rpc_timeout' => 0.0,
4646
],
4747
],
4848
'exchanges' => [

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ php composer.phar require mikemadisonweb/yii2-rabbitmq
2020
```
2121
or add
2222
```json
23-
"mikemadisonweb/yii2-rabbitmq": "^2.1.1"
23+
"mikemadisonweb/yii2-rabbitmq": "^2.2.0"
2424
```
2525
to the require section of your `composer.json` file.
2626

@@ -165,6 +165,9 @@ return [
165165
```
166166
Logger disabled by default. When enabled it will log messages into main application log or to your own log target if you specify corresponding category name. Option 'print_console' gives you additional information while debugging a consumer in you console.
167167

168+
#### Example
169+
Simple setup of Yii2 basic template with the RabbitMQ extension is available [here](https://bitbucket.org/MikeMadison/yii2-rabbitmq-test). Feel free to experiment with it and debug your existing configuration in an isolated manner.
170+
168171
Console commands
169172
-------------
170173
Extension provides several console commands:

controllers/RabbitMQController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function actionConsume(string $name): int
9999
}
100100
catch (ReflectionException $e)
101101
{
102-
$this->stderr(Console::ansiFormat("Consumer `{$name}` doesn't exist.\n", [Console::FG_RED]));
102+
$this->stderr(Console::ansiFormat("Consumer `{$name}` doesn't exist: {$e->getMessage()}\n", [Console::FG_RED]));
103103

104104
return self::EXIT_CODE_ERROR;
105105
}
@@ -134,7 +134,7 @@ public function actionPublish(string $producerName, string $exchangeName, string
134134
}
135135
catch (ReflectionException $e)
136136
{
137-
$this->stderr(Console::ansiFormat("Producer `{$producerName}` doesn't exist.\n", [Console::FG_RED]));
137+
$this->stderr(Console::ansiFormat("Producer `{$producerName}` doesn't exist: {$e->getMessage()}\n", [Console::FG_RED]));
138138

139139
return self::EXIT_CODE_ERROR;
140140
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace mikemadisonweb\rabbitmq\tests\components;
4+
5+
use mikemadisonweb\rabbitmq\components\AbstractConnectionFactory;
6+
use mikemadisonweb\rabbitmq\tests\TestCase;
7+
use PhpAmqpLib\Connection\AbstractConnection;
8+
use PhpAmqpLib\Connection\AMQPLazyConnection;
9+
10+
class AbstractConnectionFactoryTest extends TestCase
11+
{
12+
public function testCreateConnection() {
13+
$testOptions = [
14+
'name' => 'test',
15+
'url' => null,
16+
'host' => null,
17+
'port' => 5672,
18+
'user' => 'guest',
19+
'password' => 'guest',
20+
'vhost' => '/',
21+
'connection_timeout' => 3,
22+
'read_write_timeout' => 3,
23+
'ssl_context' => null,
24+
'keepalive' => false,
25+
'heartbeat' => 0,
26+
'channel_rpc_timeout' => 0.0,
27+
];
28+
29+
$factory = new AbstractConnectionFactory(AMQPLazyConnection::class, $testOptions);
30+
$connection = $factory->createConnection();
31+
$this->assertInstanceOf(AbstractConnection::class, $connection);
32+
}
33+
}

0 commit comments

Comments
 (0)