You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2019/12/10 12:30:31 UTC

[GitHub] [rocketmq-spring] caimofei opened a new issue #197: The RocketMQListener can not deserialize generic onMessage method parameter

caimofei opened a new issue #197: The RocketMQListener can not deserialize generic onMessage method parameter
URL: https://github.com/apache/rocketmq-spring/issues/197
 
 
   **Problems:**
   When definition the listener like this. the starter cannot settup
   **public class TestConsumeListener implements RocketMQListener<MsgDto<String>>**
   
   
   Recently, I tryied solve this problem,only modify the DefaultRocketMQListenerContainer class.  **Wish to improve the starter in next release.**
   1. My Main idea is use org.springframework.messaging.converter.SmartMessageConverter#fromMessage .This interface define a third parameter called "Object conversionHint".
   2. I switch the Definition of DefaultRocketMQListenerContainer#messageType to Type insteadof Class
   3. add a "private  MethodParameter onMessageParameter" member  to DefaultRocketMQListenerContainer and init it to indicate the onMessage parameter when afterPropertiesSet() 
   4. when doCovertMessage. if the messageType instanceof  ParameterizedType, then call fromMessage with the third parameter(methodParameter). The MappingJackson2MessageConverter can use it to deserialization the message.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services