Ejemplo n.º 1
0
 public function initialize()
 {
     $this->connection->connect();
     if (false === $this->channel->isInitialized()) {
         $this->channel->initialize();
     }
     if (false === $this->exchange->isInitialized()) {
         $this->exchange->initialize();
     }
     $this->initialized = true;
 }
Ejemplo n.º 2
0
 public function it_should_configure_connection(Connection $connection, Channel $channel, Exchange $exchange, Queue $queue)
 {
     $connection->connect()->shouldBeCalled();
     $channel->isInitialized()->willReturn(false);
     $channel->initialize()->shouldBeCalled();
     $exchange->isInitialized()->willReturn(false);
     $exchange->initialize()->shouldBeCalled();
     $queue->isInitialized()->willReturn(false);
     $queue->initialize()->shouldBeCalled();
     $this->initialize();
 }
Ejemplo n.º 3
0
 public function it_should_publish_message_with_routing_key_null(EventDispatcher $eventDispatcher, Exchange $exchange, Channel $channel, \AMQPExchange $AMQPExchange, Connection $connection, Identity $identity)
 {
     $message = 'foo.bar';
     $routingKey = null;
     $flags = AMQP_NOPARAM;
     $attributes = ['x-expires' => 1000];
     $event = new PublisherEvent($message, $routingKey, $flags, $attributes, $exchange->getWrappedObject());
     $successEvent = new SuccessPublisherEvent($event);
     $connection->connect()->shouldBeCalled();
     $channel->isInitialized()->willReturn(true);
     $exchange->isInitialized()->willReturn(true);
     $eventDispatcher->dispatch(PublisherEvents::PRE_PUBLISH, $event)->shouldBeCalled();
     $AMQPExchange->publish($message, $routingKey, $flags, $attributes)->willReturn(true);
     $exchange->getWrappedExchange()->willReturn($AMQPExchange);
     $eventDispatcher->dispatch(PublisherEvents::SUCCESS_PUBLISH, $successEvent)->shouldBeCalled();
     $this->publish($message, $routingKey, $flags, $attributes, false)->shouldReturn(true);
 }
Ejemplo n.º 4
0
 public function initialize()
 {
     $this->connection->connect();
     $this->channel = new \AMQPChannel($this->connection->getWrappedConnection());
     $this->initialized = true;
 }