/** * @return Stomp */ public function getStomp() { if (!$this->stomp->isConnected()) { $this->stomp->connect(Arr::get($this->credentials, 'username', ''), Arr::get($this->credentials, 'password', '')); } return $this->stomp; }
/** * Tests Stomp->unsubscribe() */ public function testUnsubscribe() { if (!$this->Stomp->isConnected()) { $this->Stomp->connect(); } $this->Stomp->subscribe($this->queue); $this->assertTrue($this->Stomp->unsubscribe($this->queue)); }
/** * {@inheritdoc} */ public function transport(SourceInterface $source) { if (!$this->client->isConnected()) { $this->client->connect(); $this->client->subscribe((string) $source); } $message = $this->client->readFrame(); $table = $this->getTableFactory()->create(); if ($message != NULL) { $this->client->ack($message); } if (!$message) { return $table; } $row = $table->getNewRow(); $row->set('command', $message->command); if (!empty($message->headers)) { foreach ($message->headers as $key => $value) { $row->set($key, $value); } } $row->set('body', $message->body); return $table; }
/** * Connect to Stomp server, if not connected. * * @throws \FuseSource\Stomp\Exception\StompException */ protected function connect() { if (!$this->stomp->isConnected()) { $this->stomp->connect(Arr::get($this->credentials, 'username', ''), Arr::get($this->credentials, 'password', '')); } }