Skip to content
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

The RocketMQListener can not deserialize generic onMessage method parameter #197

Closed
caimofei opened this issue Dec 10, 2019 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@caimofei
Copy link
Contributor

caimofei commented Dec 10, 2019

Problems:
When definition the listener like this. the starter cannot settup
public class Listener1 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.
@RongtongJin
Copy link
Contributor

RongtongJin commented Dec 10, 2019

@caimofei , good catch! Could you submit a PR to fix this issue?

@caimofei
Copy link
Contributor Author

@caimofei , good catch! Could you submit a PR to fix this issue?

i have make a pr #201

@RongtongJin
Copy link
Contributor

@caimofei OK, I will reivew the pr ASAP.

@vongosling vongosling added the bug Something isn't working label Dec 13, 2019
vongosling added a commit that referenced this issue Dec 17, 2019
[ISSUE #197] Solve the problem that RocketMQListener can not deserialize generic onMessage method parameter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants