-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Provide auto-configuration for spring-rabbit-stream #27480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -1416,13 +1423,20 @@ bom { | |||
] | |||
} | |||
} | |||
library("Rabbit AMQP Client", "5.13.0") { | |||
library("RabbitMQ AMQP Client", "5.13.0") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will result in a breaking change to the version property. It's rabbit-amqp-client.version
at the moment and this will change it to rabbitmq-amqp-client.version
. I'd prefer to leave it unchanged, but if we want to change it, it should be done in a separate issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine; I just wanted to make it consistent; will revert.
@Configuration(proxyBeanMethods = false) | ||
@ConditionalOnClass(EnableRabbit.class) | ||
@ConditionalOnProperty(prefix = "spring.rabbitmq.listener", name = "type", havingValue = "stream") | ||
public class RabbitStreamAutoConfiguration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only name classes …AutoConfiguration
if they're listed under the EnableAutoConfiguration
key in spring.factories
. This should be named RabbitStreamConfiguration
or similar and should be package-private.
* | ||
* @author Gary Russell | ||
*/ | ||
@ExtendWith(OutputCaptureExtension.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? I can't see the captured output being used anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy/paste artifact 😦
group("com.rabbitmq") { | ||
modules = [ | ||
"amqp-client" | ||
] | ||
} | ||
} | ||
library("RabbitMQ Stream Client", "0.2.0-SNAPSHOT") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an ETA for this having a tagged release? We don't want to be on a snapshot for too long and also wouldn't want to have to revert if the release isn't available before our next milestone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will ask them when it is expected to be released, spring-rabbit-stream 2.4.0-M1 uses 0.1.0 (not a snapshot), but this needs a new feature in 0.2.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wilkinsona It will be released sometime next week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent. Given that it's not long, let's wait till the release rather than adding the Sonatype snapshot repo.
@@ -58,6 +58,7 @@ dependencies { | |||
optional("org.apache.commons:commons-dbcp2") | |||
optional("org.apache.httpcomponents.client5:httpclient5") | |||
optional("org.apache.kafka:kafka-streams") | |||
optional("org.apache.qpid:proton-j") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm struggling to spot why this is needed so I tried removing it. Everything compiled cleanly. If it isn't needed we can get rid of the dependency management too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could move it to testImplementation
but the stream-client is practically unusable without it; Spring Initializr would have to add it anyway - I don't know why it is not a transitive dependency of the client. I can start a discussion with them.
...
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.rabbitmq.stream.Environment]: Factory method 'rabbitStreamEnvironment' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/qpid/proton/amqp/messaging/Section
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
... 128 more
Caused by: java.lang.NoClassDefFoundError: org/apache/qpid/proton/amqp/messaging/Section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please. I'd rather it just comes in transitively than us having to manage the version and keep things in sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates, Gary. I've left a few more comments.
I'm not sure about the need for the changes to RabbitAnnotationDrivenConfiguration
. They feel separate to adding spring-rabbit-stream support. If that's right, I'd prefer that we make them in a separate enhancement.
@@ -1128,4 +1165,48 @@ private boolean determineSslEnabled(boolean sslEnabled) { | |||
|
|||
} | |||
|
|||
public static final class Stream { | |||
|
|||
private String host = "localhost"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property needs some javadoc that'll be captured in the configuration property metadata.
|
||
private String host = "localhost"; | ||
|
||
private int port = DEFAULT_STREAM_PORT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property needs some javadoc that'll be captured in the configuration property metadata.
|
||
private int port = DEFAULT_STREAM_PORT; | ||
|
||
private String userName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property needs some javadoc that'll be captured in the configuration property metadata.
|
||
private String userName; | ||
|
||
private String password; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property needs some javadoc that'll be captured in the configuration property metadata.
@Bean(name = "rabbitListenerContainerFactory") | ||
@ConditionalOnMissingBean(name = "rabbitListenerContainerFactory") | ||
StreamRabbitListenerContainerFactory streamRabbitListenerContainerFactory(Environment rabbitStreamEnvironment, | ||
RabbitProperties properties, ObjectProvider<ConsumerCustomizer> consumerCustomizers, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RabbitProperties properties, ObjectProvider<ConsumerCustomizer> consumerCustomizers, | |
RabbitProperties properties, ObjectProvider<ConsumerCustomizer> consumerCustomizer, |
I think this makes sense given that the setter is singular.
if (containerCustomizers.getIfUnique() != null) { | ||
factory.setContainerCustomizer(containerCustomizers.getIfUnique()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (containerCustomizers.getIfUnique() != null) { | |
factory.setContainerCustomizer(containerCustomizers.getIfUnique()); | |
} | |
containerCustomizer.ifUnique(factory::setContainerCustomizer); |
@@ -871,6 +894,20 @@ public void setMissingQueuesFatal(boolean missingQueuesFatal) { | |||
|
|||
} | |||
|
|||
public static class StreamContainer extends BaseContainer { | |||
|
|||
boolean nativeListener; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property needs some javadoc that'll be captured in the configuration property metadata.
@ConditionalOnMissingBean(name = "rabbitListenerContainerFactory") | ||
StreamRabbitListenerContainerFactory streamRabbitListenerContainerFactory(Environment rabbitStreamEnvironment, | ||
RabbitProperties properties, ObjectProvider<ConsumerCustomizer> consumerCustomizers, | ||
ObjectProvider<ContainerCustomizer<StreamListenerContainer>> containerCustomizers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ObjectProvider<ContainerCustomizer<StreamListenerContainer>> containerCustomizers) { | |
ObjectProvider<ContainerCustomizer<StreamListenerContainer>> containerCustomizer) { |
I think this makes sense given that the setter is singular.
* @since 2.6 | ||
*/ | ||
@Configuration(proxyBeanMethods = false) | ||
@ConditionalOnClass(EnableRabbit.class) | ||
@ConditionalOnProperty(prefix = "spring.rabbitmq.listener", name = "type", havingValue = "stream") | ||
public class RabbitStreamConfiguration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @since 2.6 | |
*/ | |
@Configuration(proxyBeanMethods = false) | |
@ConditionalOnClass(EnableRabbit.class) | |
@ConditionalOnProperty(prefix = "spring.rabbitmq.listener", name = "type", havingValue = "stream") | |
public class RabbitStreamConfiguration { | |
*/ | |
@Configuration(proxyBeanMethods = false) | |
@ConditionalOnClass(EnableRabbit.class) | |
@ConditionalOnProperty(prefix = "spring.rabbitmq.listener", name = "type", havingValue = "stream") | |
class RabbitStreamConfiguration { |
* @since 2.6 | ||
*/ | ||
@Configuration(proxyBeanMethods = false) | ||
@ConditionalOnClass(EnableRabbit.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be conditional on StreamRabbitListenerContainerFactory
or similar as well?
@@ -1646,11 +1653,12 @@ bom { | |||
] | |||
} | |||
} | |||
library("Spring AMQP", "2.4.0-M1") { | |||
library("Spring AMQP", "2.4.0-SNAPSHOT") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When's 2.4.0-M2 due? I can't see it in the release calendar at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aug 16 - scheduled.
- new container factory (not in existing hierarchy) - also add `ContainerCustomizer` to other factories
3032d9c
to
9871270
Compare
ContainerCustomizer
to other factories