Skip to content

Commit 96fc22f

Browse files
Change description
1 parent 8bd3beb commit 96fc22f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ If you need several consumers you can list respective entries in the configurati
117117

118118
Be sure that all queues and exchanges are defined in corresponding bindings, it's up to you to set up correct message routing.
119119
#### Lifecycle events
120-
There are also some lifecycle events implemented: before_consume, after_consume, before_publish, after_publish. You can use them for any additional work you need to do before or after message been consumed/published. For example, reopen database connection for it not to be closed by a timeout as a consumer is a long-running process:
120+
There are also some lifecycle events implemented: before_consume, after_consume, before_publish, after_publish. You can use them for any additional work you need to do before or after message been consumed/published. For example, make sure that Yii knows the database connection has been closed by a timeout as a consumer is a long-running process:
121121
```php
122122
<?php
123123
// config/main.php
@@ -128,7 +128,7 @@ return [
128128
'rabbitmq' => [
129129
// ...
130130
'on before_consume' => function ($event) {
131-
if (isset(\Yii::$app->db) && \Yii::$app->db->isActive) {
131+
if (\Yii::$app->has('db') && \Yii::$app->db->isActive) {
132132
try {
133133
\Yii::$app->db->createCommand('SELECT 1')->query();
134134
} catch (\yii\db\Exception $exception) {

0 commit comments

Comments
 (0)