Skip to content

Commit 8de13b9

Browse files
committed
Don't send attributes if it's empty
1 parent 46929e0 commit 8de13b9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pkg/gps/GpsProducer.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ public function send(Destination $destination, Message $message): void
3737

3838
/** @var Topic $topic */
3939
$topic = $this->context->getClient()->topic($destination->getTopicName());
40-
$topic->publish([
41-
'data' => json_encode($message),
42-
'attributes' => $message->getAttributes(),
43-
]);
40+
41+
$params = ['data' => json_encode($message)];
42+
43+
if (count($message->getAttributes()) > 0) {
44+
$params['attributes'] = $message->getAttributes();
45+
}
46+
47+
$topic->publish($params);
4448
}
4549

4650
public function setDeliveryDelay(?int $deliveryDelay = null): Producer

0 commit comments

Comments
 (0)