Skip to content

The own implementation of ConverseService should be disable by config #8697

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

Closed
AdrianLagartera opened this issue Aug 7, 2023 · 10 comments
Closed

Comments

@AdrianLagartera
Copy link

Version: 6.0.2

Context

When you try to use the ConverseService, spring fails cuz exists both of them the mvcConversionServiceand other one named integrationConversionService its so easy to resolve it just using the qualifier, but I added this dependency in a existing project and I didn't see nothing to disable this custom ConverseService

To Reproduce

Autowire ConverseServiceusing the web starter library from spring and the spring integration

Expected behavior

Should be an option to disable the new conversion service

@AdrianLagartera AdrianLagartera added status: waiting-for-triage The issue need to be evaluated and its future decided type: enhancement labels Aug 7, 2023
@artembilan artembilan added the status: waiting-for-reporter Needs a feedback from the reporter label Aug 8, 2023
@artembilan
Copy link
Member

I'm not fully understand what is going on. Probably would be great to have some simple project to let us to reproduce.

According to your "disable" sentence I feel as you would like to have something what would remove some custom bean.
For that purpose you can look into a bean overriding option and just return null; from its @Bean method definition.
Not sure though if Spring Boot will let you to do that.

Either way it doesn't seem like something has to be done from Spring Integration perspective.
Perhaps we will be able to figure what to do next when you share more info about your concern.

Thanks

@artembilan artembilan removed the status: waiting-for-triage The issue need to be evaluated and its future decided label Aug 8, 2023
@AdrianLagartera
Copy link
Author

Well, I didn't express myself well, unfortunately I don't have a public project to share the need of the request. But basically the problem comes when I try to use the spring-integration-core library with spring-web-starter.

The problem in question is that if I try to use the ConverseService, it conflicts between these two libraries, currently I have been able to solve the problem by creating a global @Qualifier, but I would like to ask that you could disable the creation of this bean automatically in the spring-integration-core library, as it is possible in the spring-web-starter because in the latter, there is the possibility to disable the Autoconfigure that makes the ConverseService instance.

I hope this makes the reason for the issue clearer, sorry again for not explaining myself better at the beginning.

@artembilan
Copy link
Member

Well, you don't compare apples with apples. The spring-integration-core is a library registering beans for its requirements unconditionally.
The spring-web-starter is Spring Boot modules with is based on all the possible auto-configuration conventions including exclude you've mentioned.

I think we can try with a autowireCandidate = false for bean we register in Spring Integration:

		if (!registry.containsBeanDefinition(IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME)) {
			registry.registerBeanDefinition(IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME,
					new RootBeanDefinition(CustomConversionServiceFactoryBean.class));
		}

This indeed was not designed for autowiring, but rather for internal framework usage via manual calls for IntegrationUtils.getConversionService().

I can give it a shot for the current 6.2.0 and if you can test against that SNAPSHOT, and confirm that it works as expected in your project, we will back-port it to all supported versions.

Let me know if this plan works for your and I'll push the fix shortly.

@AdrianLagartera
Copy link
Author

For me it's the best solution, and I made the comparison because I think you get the idea, as soon as you upload it I'll take a look at it. Thank you

@artembilan
Copy link
Member

So, there is now a 6.2.0-SNAPSHOT. Give it a try, please.

@AdrianLagartera
Copy link
Author

Hi, I tried to follow the steps to make the jar for maven using the Gradle publishToMavenLocal task, but for some reason doesn't work as expected, I never use Gradle before, any suggestion why doesn't push the change into the local repository?.

Here you have the trace of the command: https://app.warp.dev/block/5DBbgGgGWdAX67oKQhQXcv

@artembilan
Copy link
Member

Hi @AdrianLagartera !

Sorry for not being clear with my previous comment.
You don't need to to pull the project and build it locally. We publish snapshots for changes like this.
What you will need in your project is to add https://repo.spring.io/snapshot into a list of repositories in your project and use that 6.2.0-SNAPSHOT for Spring Integration dependencies.

Re. Gradle: that publishToMavenLocal has no dependencies therefore it finished with an info like Skipping task ':publishToMavenLocal' as it has no actions.. Just because there were no artifact built to publish.
To make it working you need to do this:

 ./gradlew build publishToMavenLocal -x check -x reference -x api -x dokkaHtmlMultiModule  

so, it will build all the jars for project modules and install them to Maven local repo.
This command will also skip tests and docs. Which you definitely don't need for your case.

@AdrianLagartera
Copy link
Author

Oooh I see, really thanks for the info, I was assuming the idea of compiling my project locally. And it's good to know the command to do it anyway. I could probably check that snapshot tomorrow, and give you feedback. Thanks again

@AdrianLagartera
Copy link
Author

Hi, sorry for the delay, after testing it on my project it works as expected. Really thank you!

@artembilan artembilan added this to the 6.2.0-M2 milestone Aug 11, 2023
artembilan added a commit that referenced this issue Aug 11, 2023
Fixes #8697

The `IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME` is not designed
for end-user code autowire, rather internal framework requirement

* Mark `BeanDefinition` for `IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME`
as `setAutowireCandidate(false)`

(cherry picked from commit f9dc75c)
artembilan added a commit that referenced this issue Aug 11, 2023
Fixes #8697

The `IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME` is not designed
for end-user code autowire, rather internal framework requirement

* Mark `BeanDefinition` for `IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME`
as `setAutowireCandidate(false)`

(cherry picked from commit f9dc75c)
@artembilan
Copy link
Member

... and cherry-picked to 6.1.x & 6.0.x

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

No branches or pull requests

2 participants