Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -295,32 +295,32 @@ public static class Template {
/**
* Name of the default exchange to use for send operations.
*/
private String exchange = "";
private @Nullable String exchange;

/**
* Value of a default routing key to use for send operations.
*/
private String routingKey = "";
private @Nullable String routingKey;

/**
* Name of the default queue to receive messages from when none is specified
* explicitly.
*/
private @Nullable String defaultReceiveQueue;

public String getExchange() {
public @Nullable String getExchange() {
return this.exchange;
}

public void setExchange(String exchange) {
public void setExchange(@Nullable String exchange) {
this.exchange = exchange;
}

public String getRoutingKey() {
public @Nullable String getRoutingKey() {
return this.routingKey;
}

public void setRoutingKey(String routingKey) {
public void setRoutingKey(@Nullable String routingKey) {
this.routingKey = routingKey;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,18 @@ void autoConfigurationConfiguresRabbitAmqpTemplateWithTemplateProperties() {
});
}

@Test
void autoConfigurationDoesNotConfigureRabbitAmqpTemplateExchangeAndRoutingKeyByDefault() {
this.contextRunner
.withBean(RabbitAmqpTemplateCustomizer.class, () -> (template) -> template.setQueue("test.queue"))
.run((context) -> {
RabbitAmqpTemplate template = context.getBean(RabbitAmqpTemplate.class);
assertThat(template).hasFieldOrPropertyWithValue("defaultQueue", "test.queue");
assertThat(template).hasFieldOrPropertyWithValue("defaultExchange", null);
assertThat(template).hasFieldOrPropertyWithValue("defaultRoutingKey", null);
});
}

@Configuration(proxyBeanMethods = false)
static class MultipleRabbitAmqpTemplateCustomizersConfiguration {

Expand Down