File tree Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -11,14 +11,14 @@ Only the latest version will get new features. Bug fixes will be provided using
1111
1212| Package Version | Laravel Version | Bug Fixes Until | |
1313| -----------------| -----------------| ------------------| ---------------------------------------------------------------------------------------------|
14- | 1 | 19 | April 23th, 2025 | [ Documentation] ( https://github.com/vyuldashev/laravel-queue-rabbitmq/blob/master/README.md ) |
14+ | 1 | 20 | April 23th, 2025 | [ Documentation] ( https://github.com/vyuldashev/laravel-queue-rabbitmq/blob/master/README.md ) |
1515
1616## Installation
1717
1818You can install this package via composer using this command:
1919
2020```
21- composer require salesmessage/php-lib-rabbitmq:^1.19 --ignore-platform-reqs
21+ composer require salesmessage/php-lib-rabbitmq:^1.20 --ignore-platform-reqs
2222```
2323
2424The package will automatically register itself.
Original file line number Diff line number Diff line change 3434 },
3535 "extra" : {
3636 "branch-alias" : {
37- "dev-master" : " 1.19 -dev"
37+ "dev-master" : " 1.20 -dev"
3838 },
3939 "laravel" : {
4040 "providers" : [
Original file line number Diff line number Diff line change @@ -65,7 +65,11 @@ protected function createChannel(): AMQPChannel
6565 {
6666 try {
6767 return parent ::createChannel ();
68- } catch (AMQPConnectionClosedException ) {
68+ } catch (AMQPConnectionClosedException $ exception ) {
69+ if ($ this ->isVhostFailedException ($ exception ) && (false === $ this ->createNotExistsVhost ())) {
70+ throw $ exception ;
71+ }
72+
6973 $ this ->reconnect ();
7074 return parent ::createChannel ();
7175 }
@@ -148,5 +152,27 @@ private function addQueueToIndex(string $queue): bool
148152
149153 return $ isQueueActivated && $ isVhostActivated ;
150154 }
155+
156+ /**
157+ * @param AMQPConnectionClosedException $exception
158+ * @return bool
159+ */
160+ private function isVhostFailedException (AMQPConnectionClosedException $ exception ): bool
161+ {
162+ $ dto = new ConnectionNameDto ($ this ->getConnectionName ());
163+ $ vhostName = (string ) $ dto ->getVhostName ();
164+
165+ $ notFoundErrorMessage = sprintf ('NOT_ALLOWED - vhost %s not found ' , $ vhostName );
166+ if ((403 === $ exception ->getCode ()) && str_contains ($ exception ->getMessage (), $ notFoundErrorMessage )) {
167+ return true ;
168+ }
169+
170+ $ deletedErrorMessage = sprintf ('CONNECTION_FORCED - vhost \'%s \' is deleted ' , $ vhostName );
171+ if (str_contains ($ exception ->getMessage (), $ deletedErrorMessage )) {
172+ return true ;
173+ }
174+
175+ return false ;
176+ }
151177}
152178
You can’t perform that action at this time.
0 commit comments