Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 28d23af

Browse files
committed
[Messenger] Retain correlation id from \AmqpEnvelope when retrying a message
1 parent 1b695a9 commit 28d23af

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/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
}

src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpStamp.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public static function createFromAmqpEnvelope(\AMQPEnvelope $amqpEnvelope, self
6161
$attr['expiration'] = $attr['expiration'] ?? $amqpEnvelope->getExpiration();
6262
$attr['type'] = $attr['type'] ?? $amqpEnvelope->getType();
6363
$attr['reply_to'] = $attr['reply_to'] ?? $amqpEnvelope->getReplyTo();
64+
$attr['correlation_id'] = $attr['correlation_id'] ?? $amqpEnvelope->getCorrelationId();
6465

6566
return new self($previousStamp->routingKey ?? $amqpEnvelope->getRoutingKey(), $previousStamp->flags ?? \AMQP_NOPARAM, $attr);
6667
}

0 commit comments

Comments
 (0)