title: Return data from Laravel Jobs
body: <p>I am developing API on Laravel for mobile application.</p>
  
  <p>Methods <strong><em>will make requests to other API's</em></strong>, combine and filter data, changing it's structure etc.</p>
  
  <p>One of the requirements to app is to respond no more than 30 seconds, or not respond at all. So, I have to repeat requests as much as I have time. I trying to realize that with Laravel Queues, and currently have something like that in my Job class:</p>
  
  <pre><code>private $apiActionName;
  
  public function __construct($apiActionName)
  {
      $this-&gt;apiActionName = $apiActionName;
  }
  
  public function handle(SomeService $someService)
  {
      return $someService-&gt;{$this-&gt;apiActionName}();
  }
  </code></pre>
  
  <p>And this action code in controller:</p>
  
  <pre><code>public function someAction()
  { 
      $data = $this-&gt;dispatch(new MyJob($apiActionName));
      return response()-&gt;json($data);
  }
  </code></pre>
  
  <p>Yes, I know it is bad idea to return value from job, but expect that it's possible. However <strong>$this->dispatch()</strong> returns only queued job ID, not result of <strong>handle</strong> method. </p>
  
  <p><strong>TL;DR:</strong> How can I return data from queued Job, without saving it anywhere, and even if it have more than one tries in the queue? Maybe somebody know other ways if Jobs are not suitable for this. Any advice will be appreciated.</p>
  
  <p>Thanks in advance!</p>