|
1
|
|
|
<?php |
|
2
|
|
|
namespace PSB\Core\Transport\RabbitMq\Config; |
|
3
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
use PSB\Core\Transport\Config\TransportConfigurator; |
|
6
|
|
|
use PSB\Core\Transport\RabbitMq\RabbitMqKnownSettingsEnum; |
|
7
|
|
|
|
|
8
|
|
|
class RabbitMqTransportConfigurator extends TransportConfigurator |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* They are the same as the ones in the AMQPConnection documentation/stubs. They may vary with the |
|
12
|
|
|
* amqp library version. The ones below are for 1.6.0. |
|
13
|
|
|
* |
|
14
|
|
|
* $credentials = array( |
|
15
|
|
|
* 'host' => amqp.host The host to connect too. Note: Max 1024 characters. |
|
16
|
|
|
* 'port' => amqp.port Port on the host. |
|
17
|
|
|
* 'vhost' => amqp.vhost The virtual host on the host. Note: Max 128 characters. |
|
18
|
|
|
* 'login' => amqp.login The login name to use. Note: Max 128 characters. |
|
19
|
|
|
* 'password' => amqp.password Password. Note: Max 128 characters. |
|
20
|
|
|
* 'read_timeout' => Timeout in for income activity. Note: 0 or greater seconds. May be fractional. |
|
21
|
|
|
* 'write_timeout' => Timeout in for outcome activity. Note: 0 or greater seconds. May be fractional. |
|
22
|
|
|
* 'connect_timeout' => Connection timeout. Note: 0 or greater seconds. May be fractional. |
|
23
|
|
|
* |
|
24
|
|
|
* Connection tuning options (see http://www.rabbitmq.com/amqp-0-9-1-reference.html#connection.tune for details): |
|
25
|
|
|
* 'channel_max' => Specifies highest channel number that the server permits. 0 means standard extension limit |
|
26
|
|
|
* (see PHP_AMQP_MAX_CHANNELS constant) |
|
27
|
|
|
* 'frame_max' => The largest frame size that the server proposes for the connection, including frame header |
|
28
|
|
|
* and end-byte. 0 means standard extension limit (depends on librabbimq default frame size limit) |
|
29
|
|
|
* 'heartbeat' => The delay, in seconds, of the connection heartbeat that the server wants. |
|
30
|
|
|
* 0 means the server does not want a heartbeat. Note, librabbitmq has limited heartbeat support, |
|
31
|
|
|
* which means heartbeats checked only during blocking calls. |
|
32
|
|
|
* ) |
|
33
|
|
|
* |
|
34
|
|
|
* @param array $connectionCredentials |
|
35
|
|
|
* |
|
36
|
|
|
* @return $this |
|
37
|
|
|
*/ |
|
38
|
1 |
|
public function useConnectionCredentials(array $connectionCredentials) |
|
39
|
|
|
{ |
|
40
|
1 |
|
$this->settings->set(RabbitMqKnownSettingsEnum::CONNECTION_CREDENTIALS, $connectionCredentials); |
|
41
|
1 |
|
return $this; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Instead of the connection credentials one can use an already set up connection object. |
|
46
|
|
|
* |
|
47
|
|
|
* @param \AMQPConnection $connection |
|
48
|
|
|
* |
|
49
|
|
|
* @return $this |
|
50
|
|
|
*/ |
|
51
|
1 |
|
public function useConnection(\AMQPConnection $connection) |
|
52
|
|
|
{ |
|
53
|
1 |
|
$this->settings->set(RabbitMqKnownSettingsEnum::CONNECTION, $connection); |
|
54
|
1 |
|
return $this; |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|