/** * RabbitMq Test Client * * @return Client */ public static function getClient() { $client = new Client(new Connection('tcp://127.0.0.1:61030')); $client->setLogin('guest', 'guest'); $client->setVhostname('/'); return $client; }
/** * @return ActiveMq * @throws \Stomp\Broker\Exception\UnsupportedBrokerException */ protected function getProtocol() { $protocol = $this->client->getProtocol(); if (!$protocol instanceof ActiveMq) { throw new UnsupportedBrokerException($protocol, ActiveMq::class); } return $protocol; }
public function testAbortTransaction() { $this->assertTrue($this->Stomp->connect()); $this->assertTrue($this->simpleStomp->begin('my-id')); $this->assertTrue($this->Stomp->send('/queue/test', 'test t-id', ['transaction' => 'my-id'])); $this->assertTrue($this->simpleStomp->abort('my-id')); $this->assertTrue($this->simpleStomp->subscribe('/queue/test', 'mysubid')); $this->Stomp->getConnection()->setReadTimeout(0, 500000); $frame = $this->Stomp->readFrame(); $this->assertFalse($frame); }
/** * @inheritdoc */ public function subscribe(Consumer $consumer, ExecutionCondition $condition) { $this->stompClient->subscribe($consumer->getConfig()->getDestination()); while ($condition->isValid()) { if ($message = $this->stompClient->readMessage(10)) { $condition->incrementMessagesCount(); $result = $consumer->callback($message->getBody()); if ($result) { $message->ack(); } else { $message->nack(); } } } }
/** * Tests Stomp->unsubscribe() */ public function testUnsubscribe() { if (!$this->Stomp->isConnected()) { $this->Stomp->connect(); } $this->simpleStomp->subscribe($this->queue, 'mysubid'); $this->assertTrue($this->simpleStomp->unsubscribe($this->queue, 'mysubid')); }
/** * Tests Stomp->unsubscribe() */ public function testUnsubscribe() { if (!$this->stomp->isConnected()) { $this->stomp->connect(); } $simpleStomp = new SimpleStomp($this->stomp); $simpleStomp->subscribe('/queue/unsub'); $this->assertTrue($simpleStomp->unsubscribe('/queue/unsub')); }
/** * Read next message. * * @return bool|false|\Stomp\Transport\Frame */ public function read() { if (!$this->active || $this->reachedEnd) { return false; } if ($frame = $this->client->readFrame()) { if ($this->stopOnEnd && $frame['browser'] == 'end') { $this->reachedEnd = true; return false; } } return $frame; }
/** * Tests Stomp->connect(), send(), and subscribe() - out of order. the messages should be received in FIFO order. */ public function testAsyncSub() { $this->assertTrue($this->Stomp->connect()); $this->assertTrue($this->Stomp->send('/queue/test', 'test 1')); $this->assertTrue($this->Stomp->send('/queue/test', 'test 2')); $this->assertTrue($this->simpleStomp->subscribe('/queue/test', 'mysubid')); $frame = $this->Stomp->readFrame(); $this->assertEquals($frame->body, 'test 1', 'test 1 was not received!'); $frame = $this->Stomp->readFrame(); $this->assertEquals($frame->body, 'test 2', 'test 2 was not received!'); }
/** * ApolloMq Test Client * * @return Client */ public static function getClient() { $client = new Client(new Connection('tcp://127.0.0.1:61020')); $client->setLogin('admin', 'password'); return $client; }
/** * Not acknowledge consumption of a message from a subscription * * @param Frame $frame * @return void */ public function nack(Frame $frame) { $this->client->sendFrame($this->getProtocol()->getNackFrame($frame), false); }
/** * Tests Stomp->connect() */ public function testFailoverConnect() { $this->assertTrue($this->Stomp->connect()); }
public function testConnect() { $params = $this->client->getServerInfo(); $this->assertEquals('1.1', $params['version']); }
public function testClientWillAutoConnectOnGetProtocol() { $connection = $this->getMockBuilder(Connection::class)->setMethods(['connect', 'getParser'])->disableOriginalConstructor()->getMock(); $connection->expects($this->once())->method('connect'); $connection->expects($this->any())->method('getParser')->willReturn(new Parser()); $client = new Client($connection); try { $client->getProtocol(); } catch (ConnectionException $connectionFailed) { $this->addToAssertionCount(1); } }
/** * @return Protocol */ protected function getProtocol() { return $this->client->getProtocol(); }
public function testConnectOnApollo() { $this->assertTrue($this->client->connect(), 'Expected reachable broker.'); $this->assertInstanceOf(Apollo::class, $this->client->getProtocol(), 'Expected a Apollo broker.'); }