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 2018/03/31 02:22:54 UTC

[GitHub] zangyk opened a new issue #268: ���������������������������������������

zangyk opened a new issue #268: 咨询一下顺序消息处理问题。
URL: https://github.com/apache/rocketmq/issues/268
 
 
   咨询一下顺序消息处理问题。
   
   ConsumeMessageOrderlyService中ConsumeRequest 类的处理方式为:
   final Object objLock = messageQueueLock.fetchLockObject(this.messageQueue);
   synchronized (objLock) {
   ......
   }
   这样为了获得messageQueue的锁,这个线程会一直等待,同时也会影响到该线程对其他messageQueue处理效率。
   
   是否可以使用下面的处理方式:
   messageQueueLock改为存放每个messageQueue对应的ReentrantLock 对象,
   
   ReentrantLock objLock = messageQueueLock.fetchLockObject(this.messageQueue);
   if(objLock.tryLock())
   {
     try{
         .....
      }finally{
       objLock.unlock();
     }
   }else
   {
   ConsumeMessageOrderlyService.this.submitConsumeRequestLater(this.messageQueue,this.processQueue,10);
   }
   
   如果获取到这个messageQueue的锁,则进行消息消费;
   如果没有获取到锁,把该请求重新放到线程池中,该线程不会阻塞,可以继续处理线程池中的其他请求。这样的执行效率会提高很多。
   
   不知道这样的更改是否有其他隐患?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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