-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added rabbitmq amqp support
- Loading branch information
Showing
25 changed files
with
767 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[rabbitmq_management]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace IntegrationTesting\Driver; | ||
|
||
use PhpAmqpLib\Channel\AMQPChannel; | ||
use PhpAmqpLib\Connection\AMQPStreamConnection; | ||
|
||
/** | ||
* Class AMQPConnection | ||
* @package IntegrationTesting\Driver | ||
* @internal NOT FOR PUBLIC USE | ||
*/ | ||
class AMQPConnection | ||
{ | ||
/** | ||
* @var AMQPStreamConnection | ||
*/ | ||
private $connection; | ||
|
||
private function __construct( | ||
AMQPStreamConnection $connection | ||
) { | ||
$this->connection = $connection; | ||
$this->connection->set_close_on_destruct(true); | ||
} | ||
|
||
public static function create( | ||
string $host, | ||
int $port, | ||
string $user, | ||
string $password, | ||
string $vHost = '/', | ||
bool $insist = false, | ||
string $loginMethod = 'AMQPLAIN', | ||
string $locale = 'en_US', | ||
float $connectionTimeout = 3.0, | ||
float $readWriteTimeout = 3.0, | ||
bool $keepAlive = false, | ||
int $heartbeat = 0 | ||
): self { | ||
return new self( | ||
new AMQPStreamConnection( | ||
$host, | ||
$port, | ||
$user, | ||
$password, | ||
$vHost, | ||
$insist, | ||
$loginMethod, | ||
null, | ||
$locale, | ||
$connectionTimeout, | ||
$readWriteTimeout, | ||
null, | ||
$keepAlive, | ||
$heartbeat | ||
) | ||
); | ||
} | ||
|
||
public function connect(): void | ||
{ | ||
if (!$this->connection->isConnected()) { | ||
$this->connection->reconnect(); | ||
} | ||
} | ||
|
||
public function disconnect(): void | ||
{ | ||
if ($this->connection->isConnected()) { | ||
$this->connection->close(); | ||
} | ||
} | ||
|
||
/** | ||
* @param int $channelId | ||
* @return AMQPChannel | ||
*/ | ||
public function getChannel(int $channelId = null): AMQPChannel | ||
{ | ||
return $this->connection->channel($channelId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace IntegrationTesting\Driver; | ||
|
||
use PhpAmqpLib\Channel\AMQPChannel; | ||
|
||
/** | ||
* Interface AMQPService | ||
* @package IntegrationTesting\Driver | ||
* @internal NOT FOR PUBLIC USE | ||
*/ | ||
interface AMQPService | ||
{ | ||
public function createChannel(): AMQPChannel; | ||
|
||
public function createDurableTopicExchanges(array $exchangeNames): void; | ||
|
||
public function createDurableTopicExchange(string $name, array $arguments = []): AMQPChannel; | ||
|
||
public function forceDeleteExchange(string $name): AMQPChannel; | ||
|
||
public function forceDeleteQueue(string $name): AMQPChannel; | ||
|
||
public function purgeQueue(string $name): AMQPChannel; | ||
|
||
public function disconnect(): void; | ||
|
||
public function createDurableQueue(string $name, array $arguments = []): AMQPChannel; | ||
|
||
public function createDurableQueues(array $queueNames): void; | ||
|
||
public function bindExchangeToQueueByRoutingKeys(string $exchangeName, string $queueName, array $routingKeys): void; | ||
|
||
public function publishMessage(AMQPChannel $channel, string $body, array $properties, string $exchange, string $routingKey): void; | ||
|
||
public function consumeMessage(AMQPChannel $channel, string $consumerTag, string $queue, callable $callback): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.