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 2022/01/10 10:19:58 UTC

[GitHub] [rocketmq-spring] fookaiming opened a new issue #423: RocketMQListener can not deserialize correctly for the Type define in the arg of onMessage

fookaiming opened a new issue #423:
URL: https://github.com/apache/rocketmq-spring/issues/423


   When defining an interface as below
   
    `public interface ConsumerTemplate<T, V> extends RocketMQListener<T>, RocketMQPushConsumerLifecycleListener `
   
   And implementation as below
   
   ```
   public class ConsumerA implements ConsumerTemplate<T, V> {
       public void onMessage(T audioRecordDTO) {
           
   
       }
   }
   ```
   
   The Type of the message is simply a string, not T. I have tried to debug, it seems that the DefaultRocketMQListenerContainer cannot resolve the Type messageType correctly. 
   
   For your reference:
   Please check MethodParameter getMethodParameter()  define in DefaultRocketMQListenerContainer.java


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq-spring] fookaiming edited a comment on issue #423: RocketMQListener can not deserialize correctly for the Class implemente RocketMQListener through a middle interface

Posted by GitBox <gi...@apache.org>.
fookaiming edited a comment on issue #423:
URL: https://github.com/apache/rocketmq-spring/issues/423#issuecomment-1008890638


   It seems the Aop proxy object cannot get its super class correctly


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq-spring] fookaiming edited a comment on issue #423: RocketMQListener can not deserialize correctly for the Class implemente RocketMQListener through a middle interface

Posted by GitBox <gi...@apache.org>.
fookaiming edited a comment on issue #423:
URL: https://github.com/apache/rocketmq-spring/issues/423#issuecomment-1008890638


   It seems the ConsumerA object cannot get its super class correctly


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq-spring] fookaiming edited a comment on issue #423: RocketMQListener can not deserialize correctly for the Class implemente RocketMQListener through a middle interface

Posted by GitBox <gi...@apache.org>.
fookaiming edited a comment on issue #423:
URL: https://github.com/apache/rocketmq-spring/issues/423#issuecomment-1008890638


   The ConsumerA object cannot get its super class correctly, it should also loop through its interface 
   ```
       private Type getMessageType() {
           Class<?> targetClass;
           if (rocketMQListener != null) {
               targetClass = AopProxyUtils.ultimateTargetClass(rocketMQListener);
           } else {
               targetClass = AopProxyUtils.ultimateTargetClass(rocketMQReplyListener);
           }
           Type matchedGenericInterface = null;
           while (Objects.nonNull(targetClass)) {
               Type[] interfaces = targetClass.getGenericInterfaces();
               if (Objects.nonNull(interfaces)) {
                   for (Type type : interfaces) {
                       if (type instanceof ParameterizedType &&
                           (Objects.equals(((ParameterizedType) type).getRawType(), RocketMQListener.class) || Objects.equals(((ParameterizedType) type).getRawType(), RocketMQReplyListener.class))) {
                           matchedGenericInterface = type;
                           break;
                       }
                   }
               }
               targetClass = targetClass.getSuperclass();
           }
           if (Objects.isNull(matchedGenericInterface)) {
               return Object.class;
           }
   
           Type[] actualTypeArguments = ((ParameterizedType) matchedGenericInterface).getActualTypeArguments();
           if (Objects.nonNull(actualTypeArguments) && actualTypeArguments.length > 0) {
               return actualTypeArguments[0];
           }
           return Object.class;
       }
   ```


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq-spring] fookaiming commented on issue #423: RocketMQListener can not deserialize correctly for the Class implemente RocketMQListener through a middle interface

Posted by GitBox <gi...@apache.org>.
fookaiming commented on issue #423:
URL: https://github.com/apache/rocketmq-spring/issues/423#issuecomment-1008890638


   It seems the Aop proxy object cannot get its super class


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org