示例#1
0
 public function run()
 {
     $conn = new Connection(new \peer\URL('stomp://localhost:61613/?log=default'));
     $conn->connect();
     $dest = $conn->getDestination('/queue/producer');
     for ($i = 1; $i <= $this->amount; $i++) {
         $msg = new SendableMessage('Message ' . $i . ' of ' . $this->amount . ' in ' . $this->hashCode(), 'text/plain');
         $dest->send($msg);
         $this->out->writeLine('Wrote message ' . $i);
     }
 }
示例#2
0
 public function run()
 {
     $conn = new Connection(new \peer\URL('stomp://localhost:61613/?log=default'));
     $conn->connect();
     $self = $this;
     $sub = $conn->subscribeTo(new Subscription('/queue/producer', function ($message) use($self, $conn) {
         $self->out->writeLine('Consuming: ', \xp::stringOf($message));
         $cpy = $message->toSendable();
         $conn->getDestination('/queue/foobar')->send($cpy);
         $message->ack();
     }));
     while ($conn->consume(1)) {
     }
 }
示例#3
0
 public function run()
 {
     $conn = new Connection(new \peer\URL('stomp://localhost:61613/?log=default'));
     $conn->connect();
     $self = $this;
     $sub1 = $conn->subscribeTo(new Subscription('/queue/producer', function ($message) use($self) {
         $self->out->writeLine('Acking message ', $message->getMessageId());
         $message->ack();
     }));
     $sub2 = $conn->subscribeTo(new Subscription('/queue/foobar', function ($message) use($self) {
         $self->out->writeLine('Consumed message ', $message->getMessageId());
     }, AckMode::AUTO));
     while ($conn->consume()) {
     }
 }
示例#4
0
 public function run()
 {
     $conn = new Connection(new \peer\URL('stomp://localhost:61613/?log=default'));
     $conn->connect();
     $self = $this;
     $sub = $conn->subscribeTo(new Subscription('/queue/producer', function (ReceivedMessage $msg) use($self) {
         $self->out->writeLine('Consuming: ', \xp::stringOf($msg));
         if ($msg) {
             $msg->ack();
         }
     }));
     while ($conn->consume(1)) {
     }
     $conn->disconnect();
 }
 public function invalidCredentials()
 {
     $conn = new Connection(new \peer\URL('stomp://' . $this->host));
     $conn->connect('unknownuser', 'invalidpass');
 }