public function testClientDetectedActiveMq() { if (!$this->Stomp->isConnected()) { $this->Stomp->connect(); } $this->assertInstanceOf('\\Stomp\\Protocol\\ActiveMq', $this->Stomp->getProtocol(), 'Expected an ActiveMq Broker.'); $this->Stomp->disconnect(); }
public function testConnectOnApollo() { $this->assertTrue($this->client->connect('admin', 'password'), 'Expected reachable broker.'); $this->assertInstanceOf('\\Stomp\\Protocol\\Apollo', $this->client->getProtocol(), 'Expected a Apollo broker.'); }
// send a message while consumer is disconnected $producer->send('/topic/test', 'test-2'); echo "Message 'test-2' sent to topic\n"; // reconnect the durable consumer $consumer = new Stomp('tcp://localhost:61613'); $consumer->clientId = 'test'; $consumer->connect('admin', 'password'); $consumer->subscribe('/topic/test', null, true, true); echo "Reconnecting consumer\n"; // receive a message from the topic $msg = $consumer->readFrame(); // do what you want with the message if ($msg != null) { echo "Message '{$msg->body}' received from topic\n"; $consumer->ack($msg); } else { echo "Failed to receive a message\n"; } // disconnect if ($consumer->getProtocol() instanceof \Stomp\Protocol\ActiveMq) { // activeMq Way $consumer->unsubscribe('/topic/test'); $consumer->unsubscribe('/topic/test', null, true, true); } else { // default (apollo way) $consumer->unsubscribe('/topic/test', null, true, true); } // this message will never be seen, since no durable subscriber is present $producer->send('/topic/test', 'test-3'); $consumer->disconnect(); $producer->disconnect();