2013-03-22 49 views
0

我使用redis pub/sub with resque worker,resque在第一份工作後掛起, 我的工作任務阻塞了自然。我的理解是重新爲每一份新工作帶來新線索。resque被工作人員的工作攔截

我的工人是如下

class SendInvitation 
    @queue = :outbound_dialer 
    def self.perform(contact_type, contact_no, invitation_audio_file) 
    @invitationManager = DRbObject.new_with_uri(DRB_SERVER_URL) 

    task_id = @invitationManager.send_invitation(contact_type, contact_no, invitation_audio_file) 
    puts task_id+"is the currents task id" 
    $redis = Redis.new(:timeout=>REDIS_TIMEOUT) 
    $redis.subscribe('outbound_dialer') do |on| 
     on.message do |channel, msg| 
     data = JSON.parse(msg) 
     if(data['id'] == task_id) 
      puts 'here' 
      @invitationManager = nil 
      # exit 
     end 
     end 
    end 
    end 
end 

PS -ef導致

這裏螺紋5784阻塞resque任務,只要我殺了當前處理任務,resque與下一個任務開始,並再次在完成後開始等待 根3595 1 0 14:14? 00:00:34 /usr/bin/ruby1.9.1/usr/local/bin/resque-web root 5370 1887 0 15:40 pts/1 00:00:04 resque-2.0.0.pre.1:Forked 5784 at 1363947580 root 5784 5370 0 15:49 pts/1 00:00:00 resque-2.0.0.pre.1:處理outbound_dialer自1363947580 [SendInvitation] root 5803 2140 0 15:49 pts/2 00:00 :00的grep --color =自動resque

我已經嘗試COUNT = 5

回答

0

resque確實派生一個新的進程(不是線程)的工作。然後等待工人完成並抓住下一份工作。如果你想要更多的作業並行運行 - 運行更多的resque工作進程。

+0

那麼count = 5應該做什麼。 – 2013-03-22 11:09:58

+0

我不知道你在說什麼。 – 2013-03-22 11:12:39

+0

K我確切的要求是處理異步作業。我希望在他們入隊時儘快運行它們。我整合了resqueue,以便我可以有效地處理失敗的工作。所以,我使用正確的工具,否則我應該看看別的東西。 – 2013-03-22 12:59:36