@@ -18,17 +18,21 @@ public static function make(array $config = []): AMQPConnectionConfig
1818 {
1919 return tap (new AMQPConnectionConfig , function (AMQPConnectionConfig $ connectionConfig ) use ($ config ) {
2020 // Set the connection to a Lazy by default
21- $ connectionConfig ->setIsLazy (! in_array (
22- Arr::get ($ config , 'lazy ' ) ?? true ,
23- [false , 0 , '0 ' , 'false ' , 'no ' ],
24- true )
21+ $ connectionConfig ->setIsLazy (
22+ ! in_array (
23+ Arr::get ($ config , 'lazy ' ) ?? true ,
24+ [false , 0 , '0 ' , 'false ' , 'no ' ],
25+ true
26+ )
2527 );
2628
2729 // Set the connection to unsecure by default
28- $ connectionConfig ->setIsSecure (in_array (
29- Arr::get ($ config , 'secure ' ),
30- [true , 1 , '1 ' , 'true ' , 'yes ' ],
31- true )
30+ $ connectionConfig ->setIsSecure (
31+ in_array (
32+ Arr::get ($ config , 'secure ' ),
33+ [true , 1 , '1 ' , 'true ' , 'yes ' ],
34+ true
35+ )
3236 );
3337
3438 if ($ connectionConfig ->isSecure ()) {
@@ -38,6 +42,7 @@ public static function make(array $config = []): AMQPConnectionConfig
3842 self ::getHostFromConfig ($ connectionConfig , $ config );
3943 self ::getHeartbeatFromConfig ($ connectionConfig , $ config );
4044 self ::getNetworkProtocolFromConfig ($ connectionConfig , $ config );
45+ self ::getReadWriteTimeoutFromConfig ($ connectionConfig , $ config );
4146 });
4247 }
4348
@@ -99,4 +104,24 @@ protected static function getNetworkProtocolFromConfig(AMQPConnectionConfig $con
99104 $ connectionConfig ->setNetworkProtocol ($ networkProtocol );
100105 }
101106 }
107+
108+ protected static function getReadWriteTimeoutFromConfig (AMQPConnectionConfig $ connectionConfig , array $ config ): void
109+ {
110+ $ readTimeout = Arr::get ($ config , self ::CONFIG_OPTIONS .'.read_timeout ' );
111+ $ writeTimeout = Arr::get ($ config , self ::CONFIG_OPTIONS .'.write_timeout ' );
112+
113+ if (is_numeric ($ readTimeout )) {
114+ $ timeoutValue = (int ) $ readTimeout ;
115+ if ($ timeoutValue > 0 ) {
116+ $ connectionConfig ->setReadTimeout ($ timeoutValue );
117+ }
118+ }
119+
120+ if (is_numeric ($ writeTimeout )) {
121+ $ timeoutValue = (int ) $ writeTimeout ;
122+ if ($ timeoutValue > 0 ) {
123+ $ connectionConfig ->setWriteTimeout ($ timeoutValue );
124+ }
125+ }
126+ }
102127}
0 commit comments