Skip to content

Commit

Permalink
Don't send attributes if it's empty
Browse files Browse the repository at this point in the history
  • Loading branch information
p-pichet committed Jul 5, 2024
1 parent 46929e0 commit 8de13b9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/gps/GpsProducer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8de13b9

Please sign in to comment.