Sync.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2015 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\job;
  12. use think\queue\Job;
  13. class Sync extends Job
  14. {
  15. /**
  16. * The queue message data.
  17. *
  18. * @var string
  19. */
  20. protected $payload;
  21. public function __construct($payload)
  22. {
  23. $this->payload = $payload;
  24. }
  25. /**
  26. * Fire the job.
  27. * @return void
  28. */
  29. public function fire()
  30. {
  31. $this->resolveAndFire(json_decode($this->payload, true));
  32. }
  33. /**
  34. * Get the number of times the job has been attempted.
  35. * @return int
  36. */
  37. public function attempts()
  38. {
  39. return 1;
  40. }
  41. /**
  42. * Get the raw body string for the job.
  43. * @return string
  44. */
  45. public function getRawBody()
  46. {
  47. return $this->payload;
  48. }
  49. }