Skip to content

Auto-configuration for Rabbit Streams doesn't consider RabbitConnectionDetails #42489

Closed
@wilkinsona

Description

@wilkinsona

The auto-configuration for Rabbit Streams looks at the spring.rabbit.stream.* properties for various settings, sometimes falling back to a more general spring.rabbit property:

static EnvironmentBuilder configure(EnvironmentBuilder builder, RabbitProperties properties) {
builder.lazyInitialization(true);
RabbitProperties.Stream stream = properties.getStream();
PropertyMapper map = PropertyMapper.get();
map.from(stream.getHost()).to(builder::host);
map.from(stream.getPort()).to(builder::port);
map.from(stream.getVirtualHost())
.as(withFallback(properties::getVirtualHost))
.whenNonNull()
.to(builder::virtualHost);
map.from(stream.getUsername()).as(withFallback(properties::getUsername)).whenNonNull().to(builder::username);
map.from(stream.getPassword()).as(withFallback(properties::getPassword)).whenNonNull().to(builder::password);
return builder;
}

This fallback logic is incorrect as it ignores any RabbitConnectionDetails that may have been defined so, for example, a @ServiceConnection for Rabbit running in a container won't work correctly when using streams.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions