Skip to content

Commit 88bda43

Browse files
committed
- support of heartbeat and timeouts
1 parent a89d56b commit 88bda43

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"php-amqplib/php-amqplib": "2.6.*"
99
},
1010
"require-dev": {
11-
"laravel/framework": ">=4.0.0",
11+
"laravel/framework": ">=5.3.0",
1212
"squizlabs/php_codesniffer": "1.*",
13-
"orchestra/testbench": "3.0.4",
13+
"orchestra/testbench": "3.3.*",
1414
"phpunit/phpunit": "4.3.*"
1515
},
1616
"autoload": {

src/Connectors/AmqpConnector.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Forumhouse\LaravelAmqp\Queue\AMQPQueue;
66
use Illuminate\Queue\Connectors\ConnectorInterface;
7-
use PhpAmqpLib\Connection\AMQPConnection;
7+
use PhpAmqpLib\Connection\AMQPStreamConnection;
88

99
/**
1010
* Class AmqpConnector
@@ -22,12 +22,21 @@ class AmqpConnector implements ConnectorInterface
2222
*/
2323
public function connect(array $config)
2424
{
25-
$connection = new AMQPConnection(
25+
$connection = new AMQPStreamConnection(
2626
$config['host'],
2727
$config['port'],
2828
$config['user'],
2929
$config['password'],
30-
isset($config['vhost']) ? $config['vhost'] : '/'
30+
isset($config['vhost']) ? $config['vhost'] : '/',
31+
false,
32+
'AMQPLAIN',
33+
null,
34+
'en_US',
35+
isset($config['connection_timeout']) ? $config['connection_timeout'] : 3,
36+
isset($config['read_write_timeout']) ? $config['read_write_timeout'] : 3,
37+
null,
38+
isset($config['keepalive']) ? $config['keepalive'] : false,
39+
isset($config['heartbeat']) ? $config['heartbeat'] : 0
3140
);
3241

3342
if (!isset($config['exchange_type'])) {

src/Queue/AMQPQueue.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Illuminate\Queue\Queue;
1010
use PhpAmqpLib\Channel\AMQPChannel;
1111
use PhpAmqpLib\Connection\AMQPConnection;
12+
use PhpAmqpLib\Connection\AMQPStreamConnection;
1213
use PhpAmqpLib\Message\AMQPMessage;
1314
use PhpAmqpLib\Wire\AMQPTable;
1415

@@ -61,7 +62,7 @@ class AMQPQueue extends Queue implements QueueContract
6162
private $messageProperties;
6263

6364
/**
64-
* @param AMQPConnection $connection
65+
* @param AMQPStreamConnection $connection
6566
* @param string $defaultQueueName Default queue name
6667
* @param array $queueFlags Queue flags See a list of parameters to
6768
* \PhpAmqpLib\Channel\AMQPChannel::queue_declare. Parameters should be
@@ -74,7 +75,7 @@ class AMQPQueue extends Queue implements QueueContract
7475
* @param mixed $exchangeFlags Exchange flags
7576
*/
7677
public function __construct(
77-
AMQPConnection $connection,
78+
AMQPStreamConnection $connection,
7879
$defaultQueueName = null,
7980
$queueFlags = [],
8081
$messageProperties = [],

0 commit comments

Comments
 (0)