CallQueuedHandler.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: yunwuxin <448901948@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace think\queue;
  12. class CallQueuedHandler
  13. {
  14. public function call(Job $job, array $data)
  15. {
  16. $command = unserialize($data['command']);
  17. call_user_func([$command, 'handle']);
  18. if (!$job->isDeletedOrReleased()) {
  19. $job->delete();
  20. }
  21. }
  22. public function failed(array $data)
  23. {
  24. $command = unserialize($data['command']);
  25. if (method_exists($command, 'failed')) {
  26. $command->failed();
  27. }
  28. }
  29. }