Skip to content

Commit

Permalink
Update src/Symfony/Component/Messenger/Transport/SqsExt/Connection.php
Browse files Browse the repository at this point in the history
Co-Authored-By: François-Xavier de Guillebon <deguif@gmail.com>
  • Loading branch information
jderusse and deguif committed Aug 9, 2019
1 parent efd6d5e commit 5e9073a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 25 deletions.
Expand Up @@ -42,27 +42,6 @@ public function testConnectionSendAndGet()
$this->assertEquals(['type' => DummyMessage::class], $encoded['headers']);
}

public function testGetTheFirstAvailableMessage()
{
$this->connection->send('{"message": "Hi1"}', ['type' => DummyMessage::class]);
$this->connection->send('{"message": "Hi2"}', ['type' => DummyMessage::class]);
$wait = 0;
while ((null === $encoded1 = $this->connection->get()) && $wait++ < 50) {
usleep(5000);
}
$this->assertEquals(['type' => DummyMessage::class], $encoded1['headers']);

$wait = 0;
while ((null === $encoded2 = $this->connection->get()) && $wait++ < 50) {
usleep(5000);
}
$this->assertEquals(['type' => DummyMessage::class], $encoded2['headers']);

$messages = [$encoded2['body'], $encoded2['body']];
sort($messages);
$this->assertEquals(['{"message": "Hi1"}', '{"message": "Hi2"}'], $messages);
}

private function clearSqs()
{
$this->connection->requeuePrefetchedMessages();
Expand Down
Expand Up @@ -23,14 +23,14 @@
interface DisconnectedReceiverInterface
{
/**
* Send back prefetch messages into the queue.
* Sends back prefetch messages into the queue.
*
* @throws TransportException If there is an issue communicating with the transport
*/
public function requeuePrefetchMessages(): void;

/**
* Send explicit confirmation that the message IS NOT handled and must be re-distributed.
* Sends explicit confirmation that the message IS NOT handled and must be re-distributed.
*
* @throws TransportException If there is an issue communicating with the transport
*/
Expand Down
Expand Up @@ -74,7 +74,7 @@ public function __construct(array $configuration, HttpClientInterface $client =
* * buffer_size: number of messages to prefetch (Default: 9)
* * wait_time: long polling duration in seconds (Default: 20)
* * visibility_timeout: amount of seconds the message won't be visible
* * auto_setup: Whether the table should be created automatically during send / get (Default: true)
* * auto_setup: Whether the queue should be created automatically during send / get (Default: true)
*/
public static function fromDsn(string $dsn, array $options = [], HttpClientInterface $client = null): self
{
Expand Down Expand Up @@ -240,7 +240,7 @@ public function requeue(string $id, int $delay = 0): void

public function requeuePrefetchedMessages(): void
{
if ($this->currentResponse !== null) {
if (null !== $this->currentResponse) {
$this->currentResponse->cancel();
}

Expand Down

0 comments on commit 5e9073a

Please sign in to comment.