예제 #1
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()) {
     }
 }
예제 #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;
     $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();
 }