diff --git a/pkg/gps/GpsProducer.php b/pkg/gps/GpsProducer.php index e2e6d4046..b36fad19d 100644 --- a/pkg/gps/GpsProducer.php +++ b/pkg/gps/GpsProducer.php @@ -37,10 +37,14 @@ public function send(Destination $destination, Message $message): void /** @var Topic $topic */ $topic = $this->context->getClient()->topic($destination->getTopicName()); - $topic->publish([ - 'data' => json_encode($message), - 'attributes' => $message->getAttributes(), - ]); + + $params = ['data' => json_encode($message)]; + + if (count($message->getAttributes()) > 0) { + $params['attributes'] = $message->getAttributes(); + } + + $topic->publish($params); } public function setDeliveryDelay(?int $deliveryDelay = null): Producer