[INT-4571] MessagingMethodInvokerHelper should allow for injection of MessageHandlerMethodFactory Created: 07/Jan/19  Updated: 11/Jan/19  Resolved: 10/Jan/19

Status: Closed
Project: Spring Integration
Component/s: Core
Affects Version/s: None
Fix Version/s: 5.1.2

Type: Improvement Priority: Minor
Reporter: olegz Assignee: olegz
Resolution: Complete Votes: 0
Labels: PullRequest
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Pull Request URL: https://github.com/spring-projects/spring-integration/pull/2688

 Description   

Currently MessagingMethodInvokerHelper creates a new instance of messageHandlerMethodFactory. However in some environments (e.g., Spring Cloud Stream) that provide additional message handlers, there may already be an instance of messageHandlerMethodFactory as a bean. It would be nice if such instance could be shared, specifically to ensure consistency around the list of argument resolvers. In that case MessagingMethodInvokerHelper can do a look up in BF and see if messageHandlerMethodFactory exist and use it or create new one if it does not.

Also, to avoid conflicts may be have such instance under well known bean name. For example, integrationMessageHandlerMethodFactory.



 Comments   
Comment by Artem Bilan [ 07/Jan/19 ]

I wonder what is wrong with an existing HandlerMethodArgumentResolversHolder under the IntegrationContextUtils.ARGUMENT_RESOLVERS_BEAN_NAME bean name.
The MessagingMethodInvokerHelper has a logic like:

HandlerMethodArgumentResolversHolder handlerMethodArgumentResolversHolder =
				beanFactory.getBean(this.canProcessMessageList
											? IntegrationContextUtils.LIST_ARGUMENT_RESOLVERS_BEAN_NAME
											: IntegrationContextUtils.ARGUMENT_RESOLVERS_BEAN_NAME,
									HandlerMethodArgumentResolversHolder.class);

this.messageHandlerMethodFactory.setCustomArgumentResolvers(
							handlerMethodArgumentResolversHolder.getResolvers());

So, looks like we are covered. What am I missing, please?

Also JIRA has slightly different comment syntax to express code snippets.

Thanks for understanding

Comment by olegz [ 07/Jan/19 ]

The real issue is that DefaultMessageHandlerMethodFactory has argumentResolvers and customArgumentResolvers which is a separate issue that I intend to raise with Spring team. 

The bottom line is that I as a user should be able to control the resolvers (what they are, the order etc.) and HandlerMethodArgumentResolversHolder is not enough for me to accomplish that especially given the logic in DefaultMessageHandlerMethodFactory.afterPropertiesSet() which places custom resolvers in specific order in relation to regular resolvers.

Comment by olegz [ 09/Jan/19 ]

PR https://github.com/spring-projects/spring-integration/pull/2686/

Generated at Wed Jul 15 09:52:47 UTC 2020 using Jira 8.5.4#805004-sha1:0444eab799707f9ad7b248d69f858774aadfd250.