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/11/13 11:03:06 UTC

[GitHub] [rocketmq-spring] jamesyc33 commented on issue #167: FEATURE: 希望按照 Tag 处理, 而不是Topic以及幂等消费的扩展点

jamesyc33 commented on issue #167: FEATURE: 希望按照 Tag 处理, 而不是Topic以及幂等消费的扩展点
URL: https://github.com/apache/rocketmq-spring/issues/167#issuecomment-553353680
 
 
   我实现完了 
   tagMethodMap 是在创建 consumer 之后初始化的 tag 和 Method 的map
   写个xx基类实现 RocketMQConsumerHelper , 然后把固定业务代码: 如是否幂等消费, 以及消费后更新消费日志
   最后所有业务 Listener 都实现 xx基类即可完美解决
   
   ```
                       String tags = messageExt.getTags();
                       if (tags != null && tags.length() > 0) {
                           Method method = tagMethodMap.get(tags);
                           if (((RocketMQConsumerHelper) rocketMQListener).preConsume(messageExt)) {
                               try {
                                   method.invoke(rocketMQListener, doConvertMessage(messageExt));
                               } catch (IllegalAccessException e) {
                                   log.error(e.getMessage(), e);
                               } catch (IllegalArgumentException e) {
                                   log.error(e.getMessage(), e);
                               } catch (InvocationTargetException e) {
                                   log.error(e.getMessage(), e);
                               }finally {
                                   ((RocketMQConsumerHelper) rocketMQListener).postConsume(messageExt);
                               }
                           }
                       }
   ```

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