GH-259: Fix DLQ binding with custom routing key
Fixes https://github.com/spring-cloud/spring-cloud-stream-binder-rabbit/issues/259
Previously, a custom dead letter routing key would only be used in the binding
if the dead letter queue itself also had a dead letter routing key.
The wrong property was being tested for non-null while creating the binding.
**cherry-pick to 2.2.x, 2.1.x**
Resolves #260
Broken on 2.1.x by 75ebb08479
This commit is contained in:
committed by
Oleg Zhurakousky
parent
d9b776944b
commit
ea8c3cec36
@@ -356,7 +356,7 @@ public class RabbitExchangeQueueProvisioner
|
||||
}
|
||||
Map<String, Object> arguments = new HashMap<>(properties.getDlqBindingArguments());
|
||||
Binding dlqBinding = new Binding(dlq.getName(), DestinationType.QUEUE,
|
||||
dlxName, properties.getDlqDeadLetterRoutingKey() == null ? routingKey
|
||||
dlxName, properties.getDeadLetterRoutingKey() == null ? routingKey
|
||||
: properties.getDeadLetterRoutingKey(),
|
||||
arguments);
|
||||
declareBinding(dlqName, dlqBinding);
|
||||
|
||||
@@ -547,6 +547,7 @@ public class RabbitBinderTests extends
|
||||
extProps.setDeadLetterExchangeType(ExchangeTypes.TOPIC);
|
||||
extProps.setDeadLetterRoutingKey("customDLRK");
|
||||
extProps.setDlqDeadLetterExchange("propsUser3");
|
||||
// GH-259 - if the next line was commented, the test failed.
|
||||
extProps.setDlqDeadLetterRoutingKey("propsUser3");
|
||||
extProps.setDlqExpires(60_000);
|
||||
extProps.setDlqLazy(true);
|
||||
@@ -577,6 +578,17 @@ public class RabbitBinderTests extends
|
||||
assertThat(bindings.get(0).getDestination()).isEqualTo("propsUser3.infra");
|
||||
assertThat(bindings.get(0).getRoutingKey()).isEqualTo("foo");
|
||||
|
||||
bindings = client.getBindingsBySource("/", "customDLX");
|
||||
n = 0;
|
||||
while (n++ < 100 && bindings == null || bindings.size() < 1) {
|
||||
Thread.sleep(100);
|
||||
bindings = client.getBindingsBySource("/", "customDLX");
|
||||
}
|
||||
assertThat(bindings.size()).isEqualTo(1);
|
||||
assertThat(bindings.get(0).getSource()).isEqualTo("customDLX");
|
||||
assertThat(bindings.get(0).getDestination()).isEqualTo("customDLQ");
|
||||
assertThat(bindings.get(0).getRoutingKey()).isEqualTo("customDLRK");
|
||||
|
||||
ExchangeInfo exchange = client.getExchange("/", "propsUser3");
|
||||
n = 0;
|
||||
while (n++ < 100 && exchange == null) {
|
||||
|
||||
Reference in New Issue
Block a user