public function testPublish() { $process = $this->createProcessMock(); $this->processSerializer->expects($this->once())->method('serialize')->with($this->identicalTo($process))->will($this->returnValue($serialized = 'serialized')); $this->processProducer->expects($this->once())->method('publish')->with($this->identicalTo($serialized)); $this->producer->publish($process); }
public function notify(UrlEvent $event) { if (!$this->isEnabled() || !$event->getUrl() || !$this->producer) { return false; } try { $message = array_merge(['url' => $event->getUrl()->toArray(), 'type' => $event->getType(), 'created_on' => (new \DateTime())->format(\DateTime::ISO8601)], $event->getAdditional()); $this->producer->publish(json_encode($message)); } catch (\Exception $e) { // TODO: log message } return true; }
function it_should_add_the_trace_headers(ProducerInterface $decoratedProducer, AmqpSpanFactory $amqpSpanFactory, Tracer $tracer) { $span = new Span(Identifier::fromString('1234'), 'name', Identifier::fromString('trace')); $amqpSpanFactory->fromProducedMessage(Argument::type(AMQPMessage::class))->willReturn($span); $decoratedProducer->publish('', '', Argument::that(function (array $properties) { if (!array_key_exists('application_headers', $properties)) { return false; } $headers = $properties['application_headers']->getNativeData(); return isset($headers['X-B3-SpanId']) && isset($headers['X-B3-TraceId']); }))->shouldBeCalled(); $tracer->trace([$span])->shouldBeCalled(); $this->publish('', ''); }
/** * This method is added for compatibility reasons with a strange way of closing * RabbitMq connections. * * @see https://github.com/php-amqplib/RabbitMqBundle/pull/378 */ public function close() { return $this->decoratedProducer->close(); }
/** * @param Process $process */ public function publish(Process $process) { $this->processProducer->publish($this->processSerializer->serialize($process)); }
public function dispatch(Event $event) { $this->producer->publish($event->getBody()); }