Sfoglia il codice sorgente

Fix setting of extra attributes in AmqpHandler when handling batches of records (#1781)

One of content_type, content_encoding, message_id, user_id, app_id, delivery_mode, priority, timestamp, expiration, type or reply_to, headers.

Co-authored-by: Попов Михаил <popov.mv@betcity.ru>
Mikhail Popov 2 anni fa
parent
commit
58f503004d
1 ha cambiato i file con 8 aggiunte e 7 eliminazioni
  1. 8 7
      src/Monolog/Handler/AmqpHandler.php

+ 8 - 7
src/Monolog/Handler/AmqpHandler.php

@@ -151,13 +151,14 @@ class AmqpHandler extends AbstractProcessingHandler
 
     private function createAmqpMessage(string $data): AMQPMessage
     {
-        return new AMQPMessage(
-            $data,
-            [
-                'delivery_mode' => 2,
-                'content_type' => 'application/json',
-            ]
-        );
+        $attributes = [
+            'delivery_mode' => 2,
+            'content_type' => 'application/json',
+        ];
+        if ($this->extraAttributes) {
+            $attributes = array_merge($attributes, $this->extraAttributes);
+        }
+        return new AMQPMessage($data, $attributes);
     }
 
     /**