Skip to content

Conversation

garyrussell
Copy link
Contributor

Resolves: #9041

Spring AMQP 2.0 introduced a new container type.

Add support for auto configuration - select container type and separate discrete properties.

Resolves: spring-projects#9041

Spring AMQP 2.0 introduced a new container type.

Add support for auto configuration - select container type and separate discrete properties.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 1, 2017
@snicoll snicoll changed the title GH-9041: Spring AMQP: Support Both Container Types Spring AMQP: Support Both Container Types May 2, 2017
@snicoll snicoll self-assigned this May 2, 2017
@snicoll snicoll added priority: normal type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels May 2, 2017
@snicoll snicoll added this to the 2.0.0.M1 milestone May 2, 2017
Copy link
Member

@snicoll snicoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I've some questions, see individual comments.

public enum ContainerType {

/**
* SimpleMessageListenerContainer.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we expand that doc a little? That is showing up in IDEs and being able to understand the benefit would help.

@ConditionalOnMissingBean
public SimpleRabbitListenerContainerFactoryConfigurer rabbitListenerContainerFactoryConfigurer() {
SimpleRabbitListenerContainerFactoryConfigurer configurer = new SimpleRabbitListenerContainerFactoryConfigurer();
public RabbitListenerContainerFactoryConfigurer rabbitListenerContainerFactoryConfigurer() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer two configurer implementations with dedicated types and a base class. I understand that's quite a lot of code but that probably translates well with what that thing is configuring.

@ConditionalOnMissingBean(name = "rabbitListenerContainerFactory")
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(
SimpleRabbitListenerContainerFactoryConfigurer configurer,
public AbstractRabbitListenerContainerFactory<?> rabbitListenerContainerFactory(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

II think I'd prefer two definitions with a @ConditionalOnProperty that translates that if/else below. We prefer to expose the concrete type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started down that route, but it didn't work as I expected.

I had @ConditionalOnProperty( ... havingValue = "simple")

and @ConditionalOnProperty( ... havingValue = "direct")

...it didn't work without explicitly setting the property - but I now see there's a matchIfMissing attribute ... doh.

Will rework.


public static class Listener {

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation keys do not start with "The", "A", etc.

private final ListenerRetry retry = new ListenerRetry();

@NestedConfigurationProperty
private final SimpleContainer simple = new SimpleContainer();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So Direct only supports one property? I am a bit confused. The hierarchy of properties are becoming quite complex now so I am wondering if we should create those two namespaces at all.

Copy link
Contributor Author

@garyrussell garyrussell May 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snicoll The remaining properties (in Listener) are common to both containers (on the abstract container). The SMLC has 3 properties that are not available with the DMLC and it has one property that's not available on the SMLC. I don't mind having them at the top Listener level and simply ignoring those that don't apply, based on the containerType; it would certainly be better for backwards compatibility. I thought you preferred this hierarchical approach.

Copy link
Member

@snicoll snicoll May 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I get it now. The problem is that there are other nested namespaces that are common. So you have retry that is, and simple and direct, at the same level, that are specific.

I indeed prefer the hierarchical approach but the hierarchy is kind of wrong if you ask me. I have no idea how to fix it though so please do not act on it until we figure it out.

- Remove listener type hierarcy in properties
- Add configurer class hierarchy and conditional beans
snicoll added a commit that referenced this pull request May 5, 2017
Move `spring.rabbitmq.listener.*` to `spring.rabbitmq.listener.simple.*`
in preparation for Spring AMQP 2.0 that supports different container
types.

Closes gh-9108
See gh-9055
snicoll pushed a commit that referenced this pull request May 5, 2017
Add support for auto configuration - select container type and separate
discrete properties.

See gh-9055
@snicoll snicoll closed this in 2894e57 May 5, 2017
snicoll added a commit that referenced this pull request May 5, 2017
* pr/9055:
  Remove deprecated spring.rabbitmq.listener.* properties
  Polish "Support direct AMQP container"
  Support direct AMQP container
@snicoll
Copy link
Member

snicoll commented May 5, 2017

Thanks @garyrussell - I decided to go a different route with dedicated namespace for the two container types (and a early deprecation of the existing keys in 1.5). I've also simplified the configurer auto-config as we want both of them to be present regardless of the container type (you are free to create as many containers as you want after all).


/**
* Container type.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know all of the intimate details, but the description above for ContainerType.SIMPLE is that it is the legacy container type. Wouldn't it be better to default to the non-legacy type with the new major version of Spring Boot (and Spring AMQP)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, it's not black and white - each container has certain pros and cons. I feel that changing the container type without the user explicitly choosing to do so could cause unexpected problems for users.

I prefer that the user explicitly opt-in to using the new container. Documentation here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @garyrussell - We've created a dedicated issue to figure this out. Can you please move your comment over there? #9173

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants