Skip to content

Commit 138f91d

Browse files
Merge branch '6.0' into 6.1
* 6.0: [Console] fix tests [Cache] Fix phpdoc [Console] Fix typo in completion command help text [Messenger] Retain correlation id from \AmqpEnvelope when retrying a message
2 parents 34ee5c7 + fd01ff7 commit 138f91d

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

Tests/Transport/AmqpStampTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ public function testCreateFromAmqpEnvelope()
4242
$amqpEnvelope->method('getDeliveryMode')->willReturn(2);
4343
$amqpEnvelope->method('getPriority')->willReturn(5);
4444
$amqpEnvelope->method('getAppId')->willReturn('appid');
45+
$amqpEnvelope->method('getCorrelationId')->willReturn('foo');
4546

4647
$stamp = AmqpStamp::createFromAmqpEnvelope($amqpEnvelope);
4748

4849
$this->assertSame($amqpEnvelope->getRoutingKey(), $stamp->getRoutingKey());
4950
$this->assertSame($amqpEnvelope->getDeliveryMode(), $stamp->getAttributes()['delivery_mode']);
5051
$this->assertSame($amqpEnvelope->getPriority(), $stamp->getAttributes()['priority']);
5152
$this->assertSame($amqpEnvelope->getAppId(), $stamp->getAttributes()['app_id']);
53+
$this->assertSame($amqpEnvelope->getCorrelationId(), $stamp->getAttributes()['correlation_id']);
5254
$this->assertSame(\AMQP_NOPARAM, $stamp->getFlags());
5355
}
5456

@@ -59,15 +61,20 @@ public function testCreateFromAmqpEnvelopeWithPreviousStamp()
5961
$amqpEnvelope->method('getDeliveryMode')->willReturn(2);
6062
$amqpEnvelope->method('getPriority')->willReturn(5);
6163
$amqpEnvelope->method('getAppId')->willReturn('appid');
64+
$amqpEnvelope->method('getCorrelationId')->willReturn('foo');
6265

63-
$previousStamp = new AmqpStamp('otherroutingkey', \AMQP_MANDATORY, ['priority' => 8]);
66+
$previousStamp = new AmqpStamp('otherroutingkey', \AMQP_MANDATORY, [
67+
'priority' => 8,
68+
'correlation_id' => 'bar',
69+
]);
6470

6571
$stamp = AmqpStamp::createFromAmqpEnvelope($amqpEnvelope, $previousStamp);
6672

6773
$this->assertSame('otherroutingkey', $stamp->getRoutingKey());
6874
$this->assertSame($amqpEnvelope->getDeliveryMode(), $stamp->getAttributes()['delivery_mode']);
6975
$this->assertSame(8, $stamp->getAttributes()['priority']);
7076
$this->assertSame($amqpEnvelope->getAppId(), $stamp->getAttributes()['app_id']);
77+
$this->assertSame('bar', $stamp->getAttributes()['correlation_id']);
7178
$this->assertSame(\AMQP_MANDATORY, $stamp->getFlags());
7279
}
7380
}

Transport/AmqpStamp.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,19 @@ public static function createFromAmqpEnvelope(\AMQPEnvelope $amqpEnvelope, self
5050
{
5151
$attr = $previousStamp->attributes ?? [];
5252

53-
$attr['headers'] = $attr['headers'] ?? $amqpEnvelope->getHeaders();
54-
$attr['content_type'] = $attr['content_type'] ?? $amqpEnvelope->getContentType();
55-
$attr['content_encoding'] = $attr['content_encoding'] ?? $amqpEnvelope->getContentEncoding();
56-
$attr['delivery_mode'] = $attr['delivery_mode'] ?? $amqpEnvelope->getDeliveryMode();
57-
$attr['priority'] = $attr['priority'] ?? $amqpEnvelope->getPriority();
58-
$attr['timestamp'] = $attr['timestamp'] ?? $amqpEnvelope->getTimestamp();
59-
$attr['app_id'] = $attr['app_id'] ?? $amqpEnvelope->getAppId();
60-
$attr['message_id'] = $attr['message_id'] ?? $amqpEnvelope->getMessageId();
61-
$attr['user_id'] = $attr['user_id'] ?? $amqpEnvelope->getUserId();
62-
$attr['expiration'] = $attr['expiration'] ?? $amqpEnvelope->getExpiration();
63-
$attr['type'] = $attr['type'] ?? $amqpEnvelope->getType();
64-
$attr['reply_to'] = $attr['reply_to'] ?? $amqpEnvelope->getReplyTo();
53+
$attr['headers'] ??= $amqpEnvelope->getHeaders();
54+
$attr['content_type'] ??= $amqpEnvelope->getContentType();
55+
$attr['content_encoding'] ??= $amqpEnvelope->getContentEncoding();
56+
$attr['delivery_mode'] ??= $amqpEnvelope->getDeliveryMode();
57+
$attr['priority'] ??= $amqpEnvelope->getPriority();
58+
$attr['timestamp'] ??= $amqpEnvelope->getTimestamp();
59+
$attr['app_id'] ??= $amqpEnvelope->getAppId();
60+
$attr['message_id'] ??= $amqpEnvelope->getMessageId();
61+
$attr['user_id'] ??= $amqpEnvelope->getUserId();
62+
$attr['expiration'] ??= $amqpEnvelope->getExpiration();
63+
$attr['type'] ??= $amqpEnvelope->getType();
64+
$attr['reply_to'] ??= $amqpEnvelope->getReplyTo();
65+
$attr['correlation_id'] ??= $amqpEnvelope->getCorrelationId();
6566

6667
if (null === $retryRoutingKey) {
6768
$stamp = new self($previousStamp->routingKey ?? $amqpEnvelope->getRoutingKey(), $previousStamp->flags ?? \AMQP_NOPARAM, $attr);

0 commit comments

Comments
 (0)