Skip to content

Commit d684fcb

Browse files
committed
Fix reply-to handling logic for AMQP 1.0
The `reply-to` property from request messages is parsed to the `org.springframework.amqp.core.Address` object. This one removes the first `/` leaving `routingKey`, based on the mentioned `reply-to`, with a `queues/` prefix. The value in the `reply-to` is already encoded, so we don't need to go extra parsing logic in the `RabbitAmqpTemplate.toAmqpMessage()` in regards `com.rabbitmq.client.amqp.Message.MessageAddressBuilder` * Fix `RabbitAmqpTemplate.toAmqpMessage()` to check for `queues/` prefix before going down to the `com.rabbitmq.client.amqp.Message.MessageAddressBuilder` logic. Instead, use the `queue` value as is in the `com.rabbitmq.client.amqp.Message.to()` property adding required `/` at the beginning of the value * Revert `RabbitAmqpMessageListenerAdapter.sendResponse()` logic to `this.rabbitAmqpTemplate.send()` without modifying `replyToRoutingKey` value * Fix typos in the `Address` Javadocs * Move `log4j-slf4j-impl` to common dependencies * Fix `ObservationIntegrationTests` sorting spans by they create time to avoid race condition on assertions
1 parent b4e97f9 commit d684fcb

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ configure(javaProjects) { subproject ->
199199
testImplementation 'org.springframework:spring-test'
200200

201201
testRuntimeOnly 'org.apache.logging.log4j:log4j-jcl'
202+
testRuntimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl'
202203

203204
testImplementation 'org.junit.jupiter:junit-jupiter-api'
204205
testImplementation 'org.junit.jupiter:junit-jupiter-params'
@@ -426,7 +427,6 @@ project('spring-rabbit-stream') {
426427

427428
testImplementation 'org.testcontainers:testcontainers-rabbitmq'
428429
testImplementation 'org.testcontainers:testcontainers-junit-jupiter'
429-
testImplementation 'org.apache.logging.log4j:log4j-slf4j-impl'
430430
testImplementation 'org.springframework:spring-webflux'
431431
testImplementation 'io.micrometer:micrometer-observation-test'
432432
testImplementation 'io.micrometer:micrometer-tracing-bridge-brave'
@@ -451,7 +451,6 @@ project('spring-rabbitmq-client') {
451451

452452
testImplementation 'org.testcontainers:testcontainers-rabbitmq'
453453
testImplementation 'org.testcontainers:testcontainers-junit-jupiter'
454-
testImplementation 'org.apache.logging.log4j:log4j-slf4j-impl'
455454
}
456455
}
457456

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/support/micrometer/ObservationIntegrationTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.amqp.rabbit.support.micrometer;
1818

19+
import java.util.Comparator;
1920
import java.util.List;
2021
import java.util.concurrent.CountDownLatch;
2122
import java.util.concurrent.TimeUnit;
@@ -50,7 +51,7 @@
5051
*
5152
* @since 3.0
5253
*/
53-
@RabbitAvailable(queues = { "int.observation.testQ1", "int.observation.testQ2" })
54+
@RabbitAvailable(queues = {"int.observation.testQ1", "int.observation.testQ2"})
5455
public class ObservationIntegrationTests extends SampleTestRunner {
5556

5657
@Override
@@ -67,6 +68,7 @@ public SampleTestRunnerConsumer yourCode() {
6768
}
6869

6970
List<FinishedSpan> finishedSpans = bb.getFinishedSpans();
71+
finishedSpans.sort(Comparator.comparing(FinishedSpan::getStartTimestamp));
7072
SpansAssert.assertThat(finishedSpans)
7173
.haveSameTraceId()
7274
.hasSize(4);

spring-rabbit/src/test/resources/log4j2-test.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
</Console>
77
</Appenders>
88
<Loggers>
9-
<Logger name="org.springframework.amqp.rabbit" level="info"/>
10-
<Logger name="org.springframework.beans.factory" level="info"/>
11-
<Root level="info">
9+
<Logger name="org.springframework.amqp.rabbit" level="warn"/>
10+
<Logger name="org.springframework.beans.factory" level="warn"/>
11+
<Root level="warn">
1212
<AppenderRef ref="STDOUT" />
1313
</Root>
1414
</Loggers>

0 commit comments

Comments
 (0)